angularjs - Using $stateParams on a root (parent) controller? -
I have been using the AngularJS w / UI-router for the last two months and I am running in the same case Which I can not seem to find a beautiful solution for ... I have a step-by-step web planner application that the user should walk through to complete a command.
I have a root controller that remains out of the Ui-router scope (there is no 'state' for the root controller) where I'm trying to keep some web which is in my webplanner This information is global on every page, like the customer information and order name, which is displayed above and below the planner in the entire process.
My problem is to get this data into an angular service so that in order for it to be shared between my controllers, I need order order of which we talk about are doing. This order id is present in the IRL $ Stat Parameras, but the problem is that before joining the UI-Router, my 'Root' Controller Institution becomes, which means that I have to enter $ $ from within the controller There is no way.
When I finally got the order ID in the URL, I have used to use the Kajaya's $ broadcast
signator to tell my root controller, but this solution only Do not think "right".
// This is the root of my web app & lt; Div ng-app = "MyApp.backups.new" ng-controller = "newcounter" & gt; // This is where I have some "global" information & lt; H2 class = "dashTitle" & gt; & Lt; Sk-img class = "iBackup-add" & gt; & Lt; / Sk-img & gt; Need to be displayed. New Backup {{(Master Service Name? '-' + Master Service .name: '')}} & lt; / H2 & gt; & Lt; Div id = "wpMenuContainer" class = "wpMenuContainer" & gt; & Lt; Ul class = "wpMenu clearfix" & gt; & Lt; Li ng-repeat = "Chevron filter in Chevron: {disabled: incorrect}" ng-class = "{active: chevron active, navable: $ index , so I can not access $ states unless these child controllers are created & lt; Div ui-view & gt; & Lt; / Div & gt; & Lt; / Div & gt;
Have you tried to take advantage of the UI router?
// Custom Facting app for existing project Factor ('customfactor', function) {var current para = empty; return {getParams: function} {turn ON currently; turn ON, merge mercury: function (parameters) {currentParams = params;}};}) ; // your controller's app.controller ('NewController', ['customfactory', function (customfiner) {var path parasomms = function} {return customfinter.gateperm ()} {};}; $ scope.orderID = crash (). Order id;}]); // Listener set to '$ StateShareSuit' event to update the consultations in your factory app Set up (['$ Rootscope', 'Customfinter', Function ($ Rootscope, Custom Factor) {$ rootScope. $ On ('$ stateChangeSuccess', Function (Event, Tostate, Tupress, Seestet, Param) {Customfiners. Touparam);});}]);
In this way, you only need to reference the 'custom fabric' service in 'AppRun' and 1 controller. I have not tested it in any bella or anything, but the idea should take you on the right track.
Comments
Post a Comment