[英]AngularJS pass variable from custom directive to template
我做了一个自定义指令:
js部分:
angular.module("myDirectives", []).directive("ngShowbox", function(){
return {
restrict: "E",
scope: {
title: "="
},
template: "<a href='#' ng-click='show($event)'>{{title}}</a>",
controller: function($scope, $element){
$scope.show = function(event){
// do something...
}
}
}
});
HTML部分:
<ng-showbox title="whatToPutHere??"></ng-showbox>
我想从title属性传递一些文本,然后我的模板将显示文本。 我该怎么做?
非常感谢你 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.