如何将模块注入配置?

时间:2014-01-21 18:38:07

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

您好我发现代码示例显示了如何在某种状态下打开模态窗口: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state

但我还不知道如何将$ modal和$ scope注入:

angular.module('my-module',['ui-router']).config(function($stateProvider, $modal, $scope))

这不起作用,我也读到: how to inject dependency into module.config(configFn) in angular

所以我知道我们只能注入提供者和常量。但是如何运行这个例子:

`$stateProvider.state("items.add", {
url: "/add",
onEnter: function($stateParams, $state, $modal, $resource) {
    $modal.open({
        templateUrl: "items/add",
        resolve: {
          item: function() { new Item(123).get(); }
        },
        controller: ['$scope', 'item', function($scope, item) {
          $scope.dismiss = function() {
            $scope.$dismiss();
          };

          $scope.save = function() {
            item.update().then(function() {
              $scope.$close(true);
            });
          };
        }]
    }).result.then(function(result) {
        if (result) {
            return $state.transitionTo("items");
        }
    });
}`

P.S 我的目标是在用户更改网址时打开新的模块窗口..

1 个答案:

答案 0 :(得分:0)

尝试

angular.module('my-module',[]).config(['@stateProvider','$module','$scope', function(@stateProvider, $module, $scope))

我不太确定$ module是什么?这是你创造的角色服务吗?

相关问题