पर प्रत्येक एनजी-दोहराने का उदाहरण पास करते हैं, मुझे लगता है कि यह सरल होना चाहिए लेकिन मुझे कुछ याद आ रहा है। मैं अपने निर्देश पर नीचे ng-repeat
में flowObj
कैसे पास कर सकता हूं? मैं इसे अपने निर्देश में पास करना चाहता हूं, फिर क्लिक पर FlowObj
पर क्लिक करें, फिर कुछ तर्क लागू करें। मैंने अपने निर्देशएंगुलरजेएस एचटीएमएल में निर्देशांक
scope: {
test:"@"
}
पर टिप्पणी कोड का उपयोग करने का प्रयास किया लेकिन ऐसा लगता है कि यह मेरे सीएसएस को खराब कर रहा है।
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>
यहाँ मेरी निर्देश
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();
});
}
};
});
समाधान उत्तर के आधार पर है:
angular.module('directives', ['opsimut']).
directive('flowclick', function() {
return {
link: function(e, elem, attr) {
// scope is the directive's scope,
// elem is a jquery lite (or jquery full) object for the directive root element.
// attr is a dictionary of attributes on the directive element.
elem.bind('click', function(e1) {
debugger;
alert(e.flowObj);
},e);
}
};
});