0

Hello i found code example shows how to open modal window in certain state: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-open-a-dialogmodal-at-a-certain-state

but i have not got idea how to inject $modal and $scope into :

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

this is not working, i also read : how to inject dependency into module.config(configFn) in angular

So i know that we can only inject provider and constants. But how to run that example :

`$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 My goal is to open new module window when user change url address..

Community
  • 1
  • 1
Łukasz Woźniczka
  • 1,625
  • 3
  • 28
  • 51
  • I notice you are using ui-router, but you haven't injected ui.router into your module dependencies... – scarlz Jan 21 '14 at 18:49
  • This is only example from angular-ui faq. I havent got problem with that but i only need open modale window when user change url. For example when user add login then i only open new modal window... thats it. – Łukasz Woźniczka Jan 21 '14 at 18:53

1 Answers1

0

Try

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

I'm not quite sure what $module is though? Is that some angular service you've created?

mylescc
  • 5,720
  • 3
  • 17
  • 23
  • Sory $modal from ui-bootstrap not $module i just fix :) thanks i try – Łukasz Woźniczka Jan 21 '14 at 18:55
  • No its not working i have got err : Error: [$injector:modulerr] Failed to instantiate module turnigo-core-app due to: [$injector:unpr] Unknown provider: $modal – Łukasz Woźniczka Jan 21 '14 at 19:01
  • have you included a reference javascript file for ui-router in your index file? – mylescc Jan 21 '14 at 19:04
  • yes of course i have not got problem with ui-router and other stuff, its working fine. But now its another problem because $modal is not a angular provider. But why they show example with it – Łukasz Woźniczka Jan 21 '14 at 19:09
  • Ok just checking, its the mistake I normally make! I'm not entirely sure you can inject $scope into .config. are you sure you need? In that example you gave it doesn't seem like the inject $modal or $scope into the config fucntion – mylescc Jan 21 '14 at 19:15
  • Ok you have right in their example they do not inject $scope, and $module but they use it ... so they must hava got that object from ... i do not know ? And there is a problem, because as you mention if they show all code it will be fine... – Łukasz Woźniczka Jan 21 '14 at 19:18