(function() {
"use strict";
angular
.module("app")
.directive("myCustomDirective", myCustomDirective);
myCustomDirective.$inject = ["$compile"];
function myCustomDirective($compile) {
return {
restrict: "E",
templateUrl: "app/views/template.html",
scope: {
ui: '=info',
index: '=',
},
compile: function(tElem, tAttrs) {
// console.log(': compile => ' + tElem.html());
return {
pre: function(scope, iElem, iAttrs) {},
post: function(scope, iElem, iAttrs) {
//console.log(scope);
//console.log(iElem[0].innerHTML);
}
}
}
//controller: 'd3PhaseController'
};
}
}());
Directive template
<div class="col-md-6">
<textarea class="form-control" ng-required="true"></textarea>
</div>
Controller
vm = {
"SomeId" : "This id will fetched from the server"
};
What I am looking for is if
vm.SomeId == 1then find all the input elements in the custom directive & make it readonly
Yes I know I could easily put
<textarea class="form-control" ng-attr-readonly="{{some check}}"></textarea>
But this is kind of an overhead because I have n such controllers & n such directives.