Home  >  Article  >  Backend Development  >  javascript - angular自定义指令如何写

javascript - angular自定义指令如何写

WBOY
WBOYOriginal
2016-07-06 13:51:35728browse

现在我有这样三段类似的代码

       
       {{planStatuse.name}}

                
                {{_appType.name}}

                
                {{centerPage.name}}


我要把这三块代码写成一个自定义指令 ,但是以上代码有的有事件,有的没有事件,而且事件不一样,该如何写?

var eInput= angular.module("eInput", []);
eInput.directive('eInput',function(){

return {
    restrict: "A",
    template:' 
'+ ' '+ '{{inputList.name}}'+ '
', replace:true, scope:{ inputListes:'=' } }

});

回复内容:

现在我有这样三段类似的代码

       
       {{planStatuse.name}}

                
                {{_appType.name}}

                
                {{centerPage.name}}


我要把这三块代码写成一个自定义指令 ,但是以上代码有的有事件,有的没有事件,而且事件不一样,该如何写?

var eInput= angular.module("eInput", []);
eInput.directive('eInput',function(){

return {
    restrict: "A",
    template:' 
'+ ' '+ '{{inputList.name}}'+ '
', replace:true, scope:{ inputListes:'=' } }

});

你确认一下你每个要执行的函数是否都在controller作用域里

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn