routing - An error when I add $state service to my references in angularjs module -
i have problems use $state service on tutorial project.
here module , config definition:
(function () { "use strict"; angular.module("gamemanagement", ["ui.router", "nganimate", "ngresource"]) .config(["$stateprovider", "$urlrouterprovider","$state", function ($stateprovider, $urlrouterporvider,$state) { $urlrouterporvider.otherwise("/game/multistepform/step1"); $urlrouterprovider.otherwise("/game/home"); $stateprovider .state("home", { url: "/game/home", templateurl: "/app/game/gameview.html", controller: "gamecontroller", controlleras: "vm" }); $stateprovider .state("log", { url: "/game/log", templateurl: "/app/log/gamelogview.html", controller: "gamelogcontroller", controlleras: "vm" onenter: function () { $state.go("multistepform"); } }); $stateprovider .state("multistepform.view", { url: "/game/multistepformview", templateurl: "/app/multistepform/multistepformview.html", controller: "multistepformviewcontroller", controlleras: "multistepviewlogic" }) $stateprovider .state("multistepform.edit", { url: "/game/multistepformedit", templateurl: "/app/multistepformedit/multistepform.html", controller: "multistepformeditcontroller", controlleras: "multistepeditlogic" }) }]); })(); i want use row:
$state.go(); for purpose add $state service references but, when add to
references $state service start error:
uncaught error: [$injector:modulerr] failed instantiate module sensormanagement due to: error: [$injector:unpr] unknown provider: $state http://errors.angularjs.org/1.4.2/$injector/unpr?p0=%24state ... any idea why error above? missing?
i believe missing resolution in state. try this:
$stateprovider .state("log", { url: "/game/log", templateurl: "/app/log/gamelogview.html", controller: "gamelogcontroller", controlleras: "vm", resolve: {$state: '$state'}, onenter: function ($state) { $state.go("multistepform"); } }); see documentation more information on how onenter , onexit callbacks work. above question doesn't inject $state service correctly , thus, unable transition state(s) due callback lacking access $state.
you want remove injection config:
.config(["$stateprovider", "$urlrouterprovider", function ($stateprovider, $urlrouterprovider) {
Comments
Post a Comment