0

I configured a route using ui-route as follows,

var app = angular.module("productManagement",
                        ["common.services",
                         "ui.router",
                         "productResourceMock"]);

app.config(["$stateProvider",
    function($stateProvider){
            // Products
            $stateProvider
            .state("productList", {
                url: "/products",
                templateUrl: "app/products/productListView.html",
                controller: "ProductListCtrl as vm"
            })

    }]
);

below is my index.html

<body ng-app="productManagement">
  <div class="container">
      <div ui-view></div>   
  </div>
</body>

it is not showing any error in console, and no views shown at all !!? it used to work fine just before adding the route

this is part of the course AngularJS Line of Business Applications from www.pluralsite.com by Deborah Kuratah episode 26 "setting up the routing"

3
  • Do you definitely have productListView.html in the correct location: app/products/productListView.html? Commented Sep 18, 2017 at 20:48
  • just check if producListView.html is in the correcth path. Commented Sep 18, 2017 at 20:51
  • yes it is in the correct path : productManagement\app\products\productListView.html Commented Sep 19, 2017 at 3:41

1 Answer 1

1

You have to 1. have a default route 2. redirect to home if the state is not defined

app.config(["$stateProvider","$urlRouterProvider",
      function($stateProvider,$urlRouterProvider){
            // Products
           $urlRouterProvider.otherwise("/");
            $stateProvider
           .state("home", {
                url: "/",
                templateUrl: "app/products/productListView.html",
                controller: "ProductListCtrl as vm"
            })
            .state("productList", {
                url: "/products",
                templateUrl: "app/products/productListView.html",
                controller: "ProductListCtrl as vm"
            }}  
     }]
   );
Sign up to request clarification or add additional context in comments.

2 Comments

it worked after adding the default route, but now it is giving me Error: transition superseded angular.min.js:124, any idea why?
Could be a number of things check this out if it helps stackoverflow.com/questions/41450712/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.