How inject $stateProvider in angular application?

前端 未结 2 1790
轮回少年
轮回少年 2021-01-01 22:50

I try to use angular-ui, and try to inject $stateProvider:

html




    

        
2条回答
  •  心在旅途
    2021-01-01 23:20

    When using it in a controller you have to use $state:

    angular.module("appModule", ['ui.router']).controller('appController', ['$scope', '$state', function ($scope, $state) {
        $scope.date = new Date();
    }]);
    

    You can only use the state provider in the config, for example:

    angular.module('appModule').config(['$stateProvider', function($stateProvider){
        /* do w/e with state provider */
    })];
    

提交回复
热议问题