Javascript 如何查找自定义指令中的所有输入元素&;基于某些条件集只读
指令模板Javascript 如何查找自定义指令中的所有输入元素&;基于某些条件集只读,javascript,angularjs,dom,angular-directive,jqlite,Javascript,Angularjs,Dom,Angular Directive,Jqlite,指令模板 (function() { "use strict"; angular .module("app") .directive("myCustomDirective", myCustomDirective); myCustomDirective.$inject = ["$compile"]; function myCustomDirective($compile) { return { restrict: "E", te
(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'
};
}
}());
我要查找的是,如果vm.SomeId==1
,则查找所有输入
自定义指令中的元素&使其为只读
是的,我知道我可以很容易地
vm = {
"SomeId" : "This id will fetched from the server"
};
但这是一种开销,因为我有n个这样的控制器&n个这样的指令
vm = {
"SomeId" : "This id will fetched from the server"
};
<textarea class="form-control" ng-attr-readonly="{{some check}}"></textarea>