我正在使用輸入窗體,並且想追加包含來自該輸入的數據的flexbox。每當用戶在輸入中輸入註釋並單擊該按鈕時,Flexbox-item需要被添加到包含該輸入文本的flexbox-container中。 Flexbox確實會在點擊後追加,但沒有文字。在buttoncontroller函數中,你可以看到我試圖附加flexbox div,但「usernote」根本不顯示。我究竟做錯了什麼?使用ng-bind在輸入內容上點擊按鈕時在角度材質中添加div使用ng-bind
HTML的
<md-content layout-padding>
<form name="projectForm" class="inputForm">
<div class="inputContainer" ng-cloak>
<md-input-container class="md-block">
<label>Add a note</label>
<input required class="usernote" ng-model="usernote">
</md-input-container>
<md-input-container>
<label>Add Description</label>
<input required class="userdescription" ng-model="userdescription">
</md-input-container>
<md-checkbox ng-model="data.cb1" aria-label="Category1">
Category1
</md-checkbox>
<md-checkbox ng-model="data.cb1" aria-label="Category2">
Category2
</md-checkbox>
<div class="buttondemo" ng-controller="buttonController">
<md-button ng-click="addnoteflex()" class="md-fab" aria-label="add">
<md-icon class="material-icons">add</md-icon>
</md-button>
</div>
</div></form>
JS-
angular
.module('firstApplication', ['ngMaterial'])
.controller('buttonController', buttonController)
.controller('sideNavController',sideNavController)
.controller('speedDialController', speedDialController);
function sideNavController ($scope, $mdSidenav) {
$scope.openLeftMenu = function() {
$mdSidenav('left').toggle();
};
}
function buttonController ($scope) {
$scope.title1 = 'Button';
$scope.title4 = 'Warn';
$scope.isDisabled = true;
$scope.googleUrl = 'http://google.com';
$scope.addnoteflex=function()
{
var myflexbox = angular.element(document.querySelector('.flex-container'));
myflexbox.append("<div ng-bind='usernote' class=\"flex-item\" layout=\"row\" layout-margin> </div>");
}
}
function speedDialController ($scope) {
this.topDirections = ['left', 'up'];
this.bottomDirections = ['down', 'right'];
this.isOpen = false;
this.availableModes = ['md-fling', 'md-scale'];
this.selectedMode = 'md-scale';
this.availableDirections = ['up', 'down', 'left', 'right'];
this.selectedDirection = 'down';
}