AngularJs 打开OA详细Dialog的实现
2016-05-17 00:00
369 查看
项目中点击列表打开相应详细页的实现:
announcement.html
popup-oa-content="popup-oa-content" 指令 点击后打开新页面 该指令定义在directive.js中
directive.js
指令中注入了popupOaContentService服务,该服务在service.js中实现
popupOaContentService.prepOpenDialog 实现打开新dialog页面
service.js
config.lazyload.js
announcement.html
popup-oa-content="popup-oa-content" 指令 点击后打开新页面 该指令定义在directive.js中
[code=plain]<div class="oa-list oa-tab-body" popup-oa-content="popup-oa-content"> <div ng-repeat="item in announceList"> <div class="show-content" acrow="oaRow" actype="announcement" aid="{{item.id}}"> <div class="show-info"> <span ng-if=showAnnStic(item.isAnnStick) style="color: red;">[置顶]</span> <span>{{item.typeName}}</span> <span> {{item.title}}</span> </div> <div class="show-tool show-info"> <a class="publish-time">{{item.createDate}}</a> <span>{{item.departName}} </span> <span>{{item.createrName}}</span> </div> </div> </div> </div>
directive.js
指令中注入了popupOaContentService服务,该服务在service.js中实现
popupOaContentService.prepOpenDialog 实现打开新dialog页面
[code=plain]Sungoin.directive('popupOaContent', ["popupOaContentService", function(popupOaContentService) { 'use strict'; return { restrict: 'A', link: function(scope, element, attrs) { var $element=$(element); $element .on('click',"[acrow='oaRow']", function (e) { e.preventDefault(); var aid=$(this).attr("aid"),actype=$(this).attr("actype"),oclazy=$(this).attr("oclazy"); //承诺是否打开 if(angular.isFunction(scope.resolveContent)){ var dismiss=scope.resolveContent(aid); if(dismiss){ popupOaContentService.prepOpenDialog(aid,actype,oclazy,scope); } }else{ popupOaContentService.prepOpenDialog(aid,actype,oclazy,scope); } }); } }; }]);
service.js
[code=plain]Sungoin.service('popupOaContentService',["ngDialog",'$rootScope','RouteHelpers','$ocLazyLoad','$q','$log','APP_REQUIRES', function(ngDialog,$rootScope,helper,$ocLL, $q,$log,appRequires) { var $body = $('body'),_dialog=null; function getRequired(name) { if (appRequires.modules) for(var m in appRequires.modules) if(appRequires.modules[m].name && appRequires.modules[m].name === name) return appRequires.modules[m]; return appRequires.scripts && appRequires.scripts[name]; } return { actId:{}, getActId:function () { return this.actId; }, prepOpenDialog: function(acid,actype,oclazy,scope) { var tpl=helper.basepath("oa/"+actype+"/"+actype+"Detail.html"); this.actId=acid; if(oclazy){ var promise = $q.when(1); // empty promise promise=promise.then(function() { var whatToLoad = getRequired(oclazy); // simple error check if(!whatToLoad) return $.error('popuContent oclazy: Bad resource actype: [' + actype + '],oclazy:['+oclazy+']'); // finally, return a promise return $ocLL.load( whatToLoad ); }); } this.openDialog(tpl,actype,scope); }, dismiss: function() { /* $body.removeClass('offsidebar-open') ; $rootScope.app.offsidebarTemplate='';*/ }, openDialog:function (tpl,actype,scope) { this.closeCurrentDialog(); _dialog=ngDialog.open({ template:tpl, controller:actype+'DetailController', className: 'ngdialog-theme-default offside-content offside-content-800', scope: scope, overlay: false, closeByDocument: false, cache: true, appendTo:'.wrapper' }); }, closeCurrentDialog:function () { if(_dialog){ _dialog.close(); _dialog=null; } } }; }]);
config.lazyload.js
[code=plain]// lazyload config Sungoin.constant('APP_COLORS', { // Angular based script (use the right module name) modules: [ {name: 'ngDialog', files: ['vendor/ngDialog/js/ngDialog.min.js', 'vendor/ngDialog/css/ngDialog.min.css', 'vendor/ngDialog/css/ngDialog-theme-default.min.css'] }, ] })
相关文章推荐
- angularjs中 如何给一个跳转的页面,在跳转时注册JS控制器
- AngularJs 第一个自定义指令编写
- AngularJs:Service、Factory、Provider依赖注入使用与区别
- 【AngularJS】学习笔记
- AngularJS with MVC4 CRUD
- Using AngularJS with .NET MVC 5
- 初识AngularJS
- AngularJS 路由:ng-route 与 ui-router
- AngularJS 指令详解(业界大牛的详细学习笔记)
- AngularJS学习记录-工具方法
- angularjs实现地址的三级联动
- AngularJS的学习--$on、$emit和$broadcast的使用
- angularjs 学习笔记
- angularjs2 学习笔记(一) 开发环境搭建
- angularjs和vuejs的路由用#识别路径
- 什么是Angular? 我们为什么要学习它?
- AngularJS -- Directive参数
- Angular Material vs. Material Design Lite
- AngularJS中的$compile服务
- angularjs自定义directive指令的priority、terminal参数说明