显示在网页顶端那种能无视路由跳转随时显示需要的信息的。
我比较推荐使用directive而不是注册一个service
创建一个directive, 通知的所有模板样式放到这个模板里面例如notice_tpl.html
angular.module('demoApp', [])
.directive('noticeBox', function() {
return {
scope:{
display:'='
message:'='
},
templateURL: 'notice_tpl.html'
};
});
然后用的时候放到html标签里面(全局的化就放到ng-view外面),
<div notice-box message='data.message' display='data.show'></div>
通过$rootscope.data.message,传递消息内容 $rootscope.data.show, 控制是否显示