在stateChangeSuccess上没有使用Angular和Meteor 1.3.1

时间:2016-04-10 04:27:32

标签: angularjs meteor angular-ui-router angular-meteor

我正在尝试使这个功能与meteor 1.3.1一起工作,似乎它不起作用或者我做错了。

这是我的代码:

import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
import todosList from '../imports/components/todosList/todosList';
import navbar from '../imports/components/navbar/navbar';
import preloader from '../imports/components/preloader/preloader';

app = angular.module('exampleApp', [
  angularMeteor,
  uiRouter,
  todosList.name,
  navbar.name,
  preloader.name
]);

app.config(function($locationProvider, $stateProvider, $urlRouterProvider) {

  $locationProvider.html5Mode(true);
  $urlRouterProvider.otherwise("/");

  $stateProvider
    .state('home', {
      url: "/",
      templateUrl: "client/home/home.html"
    })
    .state('contact', {
      url: "/contact",
      templateUrl: "client/contact/contact.html"
    })
    .state('login', {
      url: "/login",
      templateUrl: "client/login/login.html"
    });
})
  .run(function ($rootScope, $state) {
    $rootScope.$on('$stateChangeSuccess', function (evt, toState) {
      console.log('test');
    });
  });

我也试过做$scope,但没有成功。

问题

如何让$stateChangeSuccess函数与angular-meteor 1.3.1一起使用,并在每次状态发生变化时执行?

0 个答案:

没有答案