我认为这应该很简单,但我错过了一些东西.我如何传递一个flowObj在我ng-repeat下面我的指令?我想将它传递给我的指令然后点击使用FlowObj然后应用一些逻辑.我尝试在我的指令中使用注释代码
scope: {
test:"@"
}
Run Code Online (Sandbox Code Playgroud)
但它似乎搞砸了我的CSS.
HTML:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="center_outer">
<div id="center_inner" ng-controller="CtrlPageFlow">
<div flowclick class="cflow" ng-repeat="flowObj in flows" >
{{flowObj.name}}
</div>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的指示
angular.module('directives', ['opsimut']).directive('flowclick', function() {
return {
/*
scope: {
test:"@" // set the attribute name on the directive's scope
},
*/
link: function(scope, elem, attr) {
elem.bind('click', function(scope) {
debugger;
alert(scope.flowObj);
//scope.name += '!';
//scope.$apply();
});
}
};
}); …Run Code Online (Sandbox Code Playgroud)