但是我不能让它工作,有没有其他角度材料的方法,我可以使用?我想在默认情况下禁用元素。main.html
<div layout="row" layout-margin>
<md-input-container flex="100" class="notifyUser-chips">
<label>Bcc</label>
<br>
<md-chips flex="100"
ng-model="notifyCtrl.bcc"
name="email"
readonly="true">
</md-chips>
<p style="color:red" ng-show="patternError">An email must contain a-z, A-Z, 0-9, or _ characters</p>
</md-input-container>
</div>发布于 2017-05-17 22:06:45
我用this fiddle复制了你的代码,对我来说运行得很好。
<div ng-app="myApp">
<div ng-controller="MyCtrl">
<div layout="column" layout-margin>
Readonly
<md-chips ng-model="bcc"
name="email"
readonly="true">
</md-chips>
Not readonly
<md-chips ng-model="bcc"
name="email">
</md-chips>
</div>
</div>
</div>
var myApp = angular.module('myApp',['ngMaterial']);
myApp.controller("MyCtrl", ["$scope","$rootScope", function($scope,$rootScope){
$scope.bcc = ['Broccoli','Cabbage','Carrot'];
}
]);检查你的angular-material和angular版本。
发布于 2017-05-17 22:33:13
如果你有ng- https://material.angularjs.org/latest/api/directive/mdChips,angular-material在文档中总是把它们当作只读,如果没有提供ng-model,芯片将被自动标记为只读。
所以这里有个解决办法...
<md-chips flex="100">
<md-chip ng-repeat="chip in notifyCtrl.bcc"
name="email"
readonly="true">{{chip}}
</md-chip>
</md-chips>https://stackoverflow.com/questions/44026802
复制相似问题