如题
指令代码如下
app.directive("info",[function(){
return {
restrict:'AE',
scope:{},
templateUrl:'views/finance/info.html',
link:function($scope,element,attrs){
}
}
}])
html页面代码
<p info id=id1></p>
<p info id=id2></p>
这两个指令渲染完成后数据会都变成id=id2的
请问是什么原因
id1, id2 are the ids of the data, use this id to retrieve the data;
I found the reason myself. It’s because I used the id to distinguish the form. There is a form in views/finance/info.html. When using multiple same instructions, the id is not unique; o(╯□╰)o
Thanks to the two people above for their answers.
I would like to ask, can id1 and id2 be added without ""? (This is a genuine question, not slander)
There is nothing wrong with it from the code point of view. I don’t know how you use this command. There is too little code posted. And how did you determine that the data became id=id2?