2

Pretty simple thing I'm trying to do. Fairly new to angular.

I just want to set the initial page that loads to be something other than the main that it is set to out of box when I generate an application

1
  • ive run yo angular:route survey. and that generated a view and script in my application which im going to begin modifying. I want when I run grunt serve (and for anyone navigating to my page), for it to go to my custom generated page instead of the default main page it has Commented Jun 19, 2015 at 14:04

3 Answers 3

8

In your config (presumably app.js with your scaffold), change the templateUrl to be the template/view that you desire.

eg:

.config(function ($routeProvider) {
  $routeProvider
    .when('/', {
      templateUrl: 'views/someOtherTemplate.html',
      controller: 'MainCtrl'
    })
   ...
});

If you're using ui-router then it's similar:

.config(function($stateProvider, $urlRouterProvider, $locationProvider) {

    $stateProvider
      .state('home', {
        url: '/',
        templateUrl: 'views/someOtherTemplate.html'
      })

    });
Sign up to request clarification or add additional context in comments.

Comments

1

If you're using the angular router then it'll be something like this:

angular.module('yourMainAppModule').config(function($routeProvider) {
  $routeProvider.when("/", {
    templateUrl: "youTemplate.html",
    controller: "YourHomeController"
  })
});

You can read more about setting up your app's routes by looking at when() in the Angular Docs.

Comments

0

Above methods where not working for me, giving the url field an empty value worked great with ui-router :

        $stateProvider
        .state('home', {
            url: '',
            templateUrl: 'views/homepage.html',
            controller: 'AppCtrl'
        })

Comments

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.