[英]Angular multiple instances of same directive, scope is not isolated , same scope
我在页面上多次使用指令,例如
$scope.stylusright[0] = 330;
var appendHtml = $compile('<directive-history rightstylus="{{stylusright[0]}}"></directive-history>')($scope);
$element.append(appendHtml);
$scope.stylusright[1] = 660;
var appendHtml = $compile('<directive-history rightstylus="{{stylusright[1]}}"></directive-history>')($scope);
$element.append(appendHtml);
我的指令看起来像
angular.module('mymodule').directive('directiveHistory', function ($compile)
{
return {
restrict: 'E',
scope: true,
transclude: true,
templateUrl: 'directive.history.html',
scope: {
rightstylus: "@",
},
...
我的问题是,当同一指令多次添加到同一页面时,它们的作用域将变为相同。 当我在第二个指令中更改$ scope.stylusright [1]时,也会在所有其他指令中进行更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.