AngularJS - Dynamic $StateProvider

前端 未结 2 1711
醉梦人生
醉梦人生 2021-02-06 19:05

I am eagerly trying to create a dyanmic $StateProvider:

Standard static $StateProvider:

    $stateProvider
      .state(\'main\         


        
2条回答
  •  猫巷女王i
    2021-02-06 19:39

    I think you're calling $stateProvider.state(...) incorrectly, it takes a state ID and then the configuration object.

    Assuming your name properties are valid and unique you should just be able to do this (or adjust it as needed):

    angular.forEach(states, function(state) {
        $stateProvider.state(state.name, state);
    });
    

提交回复
热议问题