Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何查找自定义指令中的所有输入元素&;基于某些条件集只读_Javascript_Angularjs_Dom_Angular Directive_Jqlite - Fatal编程技术网

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>