我想在我的所有视图中添加一段代码,以在顶部显示一个通知栏,以便通知用户。
我正在尝试使用指令来做到这一点。检查这个简单的示例:http: //jsfiddle.net/dirkom/wsrb6/2/
HTML:
<bca-notification></bca-notification>
指示:
.directive('bcaNotification', function () {
var notification = '<div id="notification" ng-init="showThis=true" ng-show="showThis">' +
'Error message<a id="close" ng-click="showThis = false">Close</a></div>';
return({
template: notification,
restrict: "E"
});
这是正确的方法吗?
提前致谢!