- This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Angular.js experience needed please!!!
So my co-developer and I are having trouble deciding the best course of action. Currently, we are developing a single-page webapp using angular. We currently have a skeleton index file that will be injected with different views based on the nav link that is clicked. This works fine, however, this method loads all img, css and js files at once….but it does NOT LOAD ALL VIEWS ON PAGE LOAD…..were using ngRoute to switch between views and what happens is the view is fetched and loaded on nav click…is this the best way? or should we load the entire site at once and use css transitions only to switch views? This is our debate lol help break the tie!! Im voting for the current way bc it is extremely organized and efficient.
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.