Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Angular.js experience needed please!!! Reply To: Angular.js experience needed please!!!

#180006
Alen
Participant

We currently have a skeleton index file that will be injected with different views based on the nav link that is clicked.

A partial should be injected not the index file.

Sample index file:


<body>
  <div class="content" ng-view></div>
</body>

Then on click you would inject the partial into the view. Then your controller will direct traffic, something like:


var app = angular.module('app', []);

app.config(function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'partials/home.html',
        controller: 'HomeController'
      })
      .when('/about', {
        templateUrl: 'partials/about.html',
        controller: 'AboutController'
      })
      .otherwise({
        redirectTo: '/'
      });
  });

In this case, when you request / it will load the home.html partial in partials directory.