template stateprovider stateparams sref example angularjs angular-ui angular-ui-router

stateprovider - ui sref angularjs



¿Cómo activar UI-Router View Load eventos? (2)

Probando ui-router por primera vez, pero probando los eventos en este momento y parece que no entiendo cómo desencadenar $ viewContentLoaded o Loading. Aunque, tengo stageChangeSuccess, etc trabajando! Acabo de enviarlo todo a http://punkbit.com/space_competition/ pero también agregué algo de código aquí. Esperaba activar los eventos cuando se carga una nueva vista en ui-view. ¡Pero supongo que me estoy perdiendo algo aquí!

<div class="pure-g"> <div class="pure-u-1" ui-view> </div> </div> <!-- s: template partials --> <script type="text/ng-template" id="menu.html"> <div class="pure-menu pure-menu-open pure-menu-horizontal"> <ul> <li><a href="#/home">home</a></li> <li class="pure-menu-selected"><a href="#/like_gate">like_gate</a></li> <li><a href="#/terms_and_conditions">terms_and_conditions</a></li> <li><a href="#/enter_competition">enter_competition</a></li> </ul> </div> </script> <script type="text/ng-template" id="home.html"> <p>home.html template! fbLike is {{fbLike}}</p> </script> <script type="text/ng-template" id="enter_competition.html"> <p>enter_competition.html template!</p> </script> <script type="text/ng-template" id="like_gate.html"> <p>like.html template!</p> </script> <script type="text/ng-template" id="terms_and_conditions.html"> <p>terms_and_conditions.html template!</p> </script> <!-- e: template partials -->

main.js

angular.module("space_competition", [''ui.router'']) .config(function($stateProvider, $urlRouterProvider, $locationProvider){ $stateProvider .state(''home'', { url: ''/home'', templateUrl: ''home.html'', controller: ''homeCtrl'', resolve: { fb_like: ''fbLike'' } }) .state(''enter_competition'', { url: ''/enter_competition'', templateUrl: ''enter_competition.html'', controller: ''enterCompetitionCtrl'', resolve: { fb_like: ''fbLike'' } }) .state(''like_gate'', { url: ''/like_gate'', templateUrl: ''like_gate.html'', controller: ''likeGateCtrl'' }) .state(''terms_and_conditions'', { url: ''/terms_and_conditions'', templateUrl: ''terms_and_conditions.html'', controller: ''termsAndConditionsCtrl'' }); $urlRouterProvider.otherwise("/home"); //$locationProvider.hashPrefix(''!''); }) .run(function($rootScope){ $rootScope .$on(''$stateChangeStart'', function(event, toState, toParams, fromState, fromParams){ console.log("State Change: transition begins!"); }); $rootScope .$on(''$stateChangeSuccess'', function(event, toState, toParams, fromState, fromParams){ console.log("State Change: State change success!"); }); $rootScope .$on(''$stateChangeError'', function(event, toState, toParams, fromState, fromParams){ console.log("State Change: Error!"); }); $rootScope .$on(''$stateNotFound'', function(event, toState, toParams, fromState, fromParams){ console.log("State Change: State not found!"); }); $rootScope .$on(''$viewContentLoading'', function(event, viewConfig){ console.log("View Load: the view is loaded, and DOM rendered!"); }); $rootScope .$on(''$viewcontentLoaded'', function(event, viewConfig){ console.log("View Load: the view is loaded, and DOM rendered!"); }); }) .controller(''homeCtrl'', function($scope, fbLike){ $scope.fbLike = fbLike.liked(); }) .controller(''enterCompetitionCtrl'', function($scope, fbLike){ fbLike.liked(); }) .controller(''likeGateCtrl'', function($scope){ }) .controller(''termsAndConditionsCtrl'', function($scope){ }) .factory(''fbLike'', function($http, $q){ return { liked: function(){ return true; } }; });

¿Alguien experimentado podría echarle un vistazo por favor?

Gracias: D



parece que tienes $viewcontentLoaded lugar de $viewContentLoaded . ¿Te olvidaste de camel-case-capitalize the C ?