Closed shivkumarganesh closed 8 years ago
What version of things are you running? Have you looked at the compiled code to see if its the same?
This is what it compiles to, Is there anything wrong could you please assist me @eddiemonge
_angular2.default.module('chpApp', [_angularUiRouter2.default, _angularAnimate2.default, _angularBootstrapNpm2.default, _angularFormly2.default, _angularFormlyTemplatesBootstrap2.default, _angularMessages2.default, _angularLoadingBar2.default, 'ngNotificationsBar', 'jkuri.datepicker', 'LocalStorageModule', 'ncy-angular-breadcrumb', 'mgo-angular-wizard', 'luegg.directives', 'ngToast', 'ui.mask',
/*Application Modules*/
_angularNvd2.default, _url2.default, _menu2.default, _header2.default, _breadcrumb2.default, _auth2.default, _dashboard2.default, _programs2.default, _device2.default
]).config(_routeConfig2.default).run(['$rootScope', function($rootScope) {
$rootScope.$on("$stateChangeStart", function(evt, to, toP, from, fromP) {
console.log("Start: " + message(to, toP, from, fromP));
});
$rootScope.$on("$stateChangeSuccess", function(evt, to, toP, from, fromP) {
console.log("Success: " + message(to, toP, from, fromP));
});
$rootScope.$on("$stateChangeError", function(evt, to, toP, from, fromP, err) {
console.log("Error: " + message(to, toP, from, fromP), err);
});
}]);
why does it say angular2? could you create a plnkr example with the compiled code?
I am using Webpack and it uses the following statements while compiling
`var _angular = __webpack_require__(122);
var _angular2 = _interopRequireDefault(_angular);`
Since its a big project I can't just extract a small piece. Is there anything wrong in my code?
just a quick glance doesnt look like it
It looks like you copied/pasted this logging code from the http://bit.ly/UIR-Plunk but you didn't copy the message()
function
function message(to, toP, from, fromP) {
return from.name + angular.toJson(fromP) + " -> " + to.name + angular.toJson(toP);
}
$rootScope.$on("$stateChangeStart", function(evt, to, toP, from, fromP) { console.log("Start: " + message(to, toP, from, fromP)); });
$rootScope.$on("$stateChangeSuccess", function(evt, to, toP, from, fromP) { console.log("Success: " + message(to, toP, from, fromP)); });
$rootScope.$on("$stateChangeError", function(evt, to, toP, from, fromP, err) { console.log("Error: " + message(to, toP, from, fromP), err); });
You should have seen an error about ReferenceError: message is not defined
in your console.
@christopherthielen I am using alpha release and one of the person prompted me as mentioned below in stackoverflow http://bit.ly/20VG3Ha. Is there a problem with the Release where the statechange is deprecated.
Use they are deprecated and disabled. See the release notes at https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0
In 1.0 you can enable the trace service:
.run($trace) {
$trace.enable(1)
}
release notes:
All state events, (i.e. $stateChange* and friends) are deprecated and disabled by default; re-enable them by including the ng1/stateEvents.js file, and depend on the ui.router.state.events angular module in your application.
are there any alternatives or replacements for "$stateChange* and friends" so far?
Newer versions are following something called transition hooks. They work pretty well and are well documented too. I am using those for now. On 7 Apr 2016 14:39, "Oliver Haase" notifications@github.com wrote:
are there any alternatives or replacements for "$stateChange* and friend" ? :)
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/angular-ui/ui-router/issues/2577#issuecomment-207042728
Hi, I am using UI-Router and want to check for the
$stateChangeStart
event but I am not able to catch it anyways. I have written the code in the run block but nothing works out there. Is there a bug or am I doing something wrongLet me know if there is something I need to change. This does not work at all. But the applciation is working pretty smooth