angularjs - render templates for a specific route directly from the server -
when using routes in angular.js application possible render template specific route directly server , attach controller it?
for example, have application login screen , screen shows content when user logged in.
- when user isn't logged in , opens application cool if render template login route directly server , attach right controller it. user gets feedback directly , doesn't have wait until angular.js bootstrapped before page shows anything.
- when user logged in , opens application want render template content page directly server , attach controller when don't use routing angular.js (with ng-controller example). stuff on page cloacked because needs controller attached before shows useful.
i'm quiet new angular, experimented bit angular.js , routing api. in test application when open it, first shows nothing , when angular bootstrapped renders view "/" route. want show view direcly because of information doesn't need controller attached it. other things can hide using ng-cloack or ng-bind. way cleaner.
doesn has idea how achieve this? if explanation still bit unclear, let me know. found hard explain ...
kind regards,
daan
honestly, never tried solution, guess controller template has not static file.
need provide path template, created dynamically.
example:
angular.module('myapp', ['myapp.filters', 'myapp.services', 'myapp.directives', 'myapp.controllers']). config(['$routeprovider', function($routeprovider) { $routeprovider.when('/login', {templateurl: 'partials/login.php', controller: 'loginctrl'}); $routeprovider.when('/logout', {templateurl: 'partials/logout.php', controller: 'logoutctrl'}); $routeprovider.otherwise({redirectto: '/login'}); }]);
login.php , logout.php must return valide angularjs template.
never tried this, should work.
don't know if angular way of doing things.
Comments
Post a Comment