Home › Forums › JavaScript › Angular.js experience needed please!!! › Reply To: Angular.js experience needed please!!!
August 20, 2014 at 9:45 am
#180006
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.