user2683428
user2683428

Reputation: 61

How to dynamically set field level readonly in angular js

I am trying to create a directive, which will tell me that the field is readonly or not.

myApp.directive('ngFieldLevelPolicies', function () {
    return {
        restrict: 'A',
        require: 'ngModel',
        link: function (scope, element, attrs, ngModelCtrl) {
            element.bind('input', function () {
                scope.$apply(function () {
                    //debugger;
                    var fieldPolicies = scope[attrs.ngModel.split('.')[0]].
                                FieldLevelPolicies;
                    SetRights(element, attrs.ngModel.split('.')[0],
                                attrs.ngModel.split('.')[1], fieldPolicies);
                });
            });
        }
    };
  });

I want this directive to be added as an attribute and called when binding is happeing.

Upvotes: 4

Views: 1824

Answers (1)

Jon7
Jon7

Reputation: 7215

It seems like what you're looking for is ngReadonly.

Upvotes: 3

Related Questions