Reputation: 7113
I have read angular material documentation and they have readonly attribute to disable the element. But I can't get it to work, is there any other Angular Material approach that I can use? I want to disabled element by default. 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>
Upvotes: 1
Views: 3781
Reputation: 7113
If you have ng-model, angular-material will always treat them as editable.Also in docs says If no ng-model is provided, the chips will automatically be marked as readonly https://material.angularjs.org/latest/api/directive/mdChips.
So here is the fix...
<md-chips flex="100">
<md-chip ng-repeat="chip in notifyCtrl.bcc"
name="email"
readonly="true">{{chip}}
</md-chip>
</md-chips>
Upvotes: 0
Reputation: 1296
I replicated your code in this fiddle, for me it's working fine.
<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'];
}
]);
Check your angular-material and angular versions.
Upvotes: 0