我想咨询一下,在angular自定义指令中,创建一个可以随时修改的指令呢?比如创建一个bar,可以随时在controller中修改它的属性,或者通过service修改?有些困惑。。。
作为用过 angular 的码农,表示看不懂你的问题。坐等大神!
你要修改啥,修改template啊,还是只是修改scope中的东西?
把业务需求场景描述下,问题看不太懂
楼主说的是指令怎么传值吧
ng指令的编译和链接有什么区别?
@qinyang912 偶遇。。。
我也看不懂你的问题
@wwhgtt 笑脸
看不懂问题 建议用英文解释下😁😁 自豪地采用 CNodeJS ionic
这个回答能解答你的疑惑么?https://github.com/i5ting/ionic_ninja/blob/master/sidemenu/sidemenu.md#查看navviewjs
IonicModule.constant('$ionicNavViewConfig', { transition: 'slide-left-right-ios7' }); IonicModule .directive('ionNavView', [ '$ionicViewService', '$state', '$compile', '$controller', '$animate', function( $ionicViewService, $state, $compile, $controller, $animate) { // IONIC's fork of Angular UI Router, v0.2.7 // the navView handles registering views in the history, which animation to use, and which var viewIsUpdating = false; var directive = { restrict: 'E', terminal: true, priority: 2000, transclude: true, controller: function(){}, compile: function (element, attr, transclude) { return function(scope, element, attr, navViewCtrl) { var viewScope, viewLocals, name = attr[directive.name] || attr.name || '', onloadExp = attr.onload || '', initialView = transclude(scope); // Put back the compiled initial view element.append(initialView); // Find the details of the parent view directive (if any) and use it // to derive our own qualified view name, then hang our own details // off the DOM so child directives can find it. var parent = element.parent().inheritedData('$uiView'); if (name.indexOf('@') < 0) name = name + '@' + ((parent && parent.state) ? parent.state.name : ''); var view = { name: name, state: null }; element.data('$uiView', view); var eventHook = function() { if (viewIsUpdating) return; viewIsUpdating = true; try { updateView(true); } catch (e) { viewIsUpdating = false; throw e; } viewIsUpdating = false; }; scope.$on('$stateChangeSuccess', eventHook); // scope.$on('$viewContentLoading', eventHook); updateView(false); function updateView(doAnimate) { //===false because $animate.enabled() is a noop without angular-animate included if ($animate.enabled() === false) { doAnimate = false; } var locals = $state.$current && $state.$current.locals[name]; if (locals === viewLocals) return; // nothing to do var renderer = $ionicViewService.getRenderer(element, attr, scope); // Destroy previous view scope if (viewScope) { viewScope.$destroy(); viewScope = null; } if (!locals) { viewLocals = null; view.state = null; // Restore the initial view return element.append(initialView); } var newElement = jqLite('<div></div>').html(locals.$template).contents(); var viewRegisterData = renderer().register(newElement); // Remove existing content renderer(doAnimate).leave(); viewLocals = locals; view.state = locals.$$state; renderer(doAnimate).enter(newElement); var link = $compile(newElement); viewScope = scope.$new(); viewScope.$navDirection = viewRegisterData.navDirection; if (locals.$$controller) { locals.$scope = viewScope; var controller = $controller(locals.$$controller, locals); element.children().data('$ngControllerController', controller); } link(viewScope); var viewHistoryData = $ionicViewService._getViewById(viewRegisterData.viewId) || {}; viewScope.$broadcast('$viewContentLoaded', viewHistoryData); if (onloadExp) viewScope.$eval(onloadExp); newElement = null; } }; } }; return directive; }]);
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
作为用过 angular 的码农,表示看不懂你的问题。坐等大神!
你要修改啥,修改template啊,还是只是修改scope中的东西?
把业务需求场景描述下,问题看不太懂
楼主说的是指令怎么传值吧
ng指令的编译和链接有什么区别?
@qinyang912 偶遇。。。
我也看不懂你的问题
@wwhgtt 笑脸
看不懂问题 建议用英文解释下😁😁 自豪地采用 CNodeJS ionic
这个回答能解答你的疑惑么?https://github.com/i5ting/ionic_ninja/blob/master/sidemenu/sidemenu.md#查看navviewjs