Angularjs Page contents change according to pages set in routers -
i trying create simple website angularjs
i have controller:
nglesson.controller('pages_contents', ['$scope', function ($scope) { $scope.homepage = { pageuri: 'home', pagename: 'home', pagedescription: 'bla bla bla', pagecontent: 'bla bla bla bla blabla' }; $scope.aboutpage = { pageuri: 'about', pagename: 'about', pagedescription: 'bla bla bla', pagecontent: 'bla bla bla bla blabla' }; // , on... }]);
i have router rules:
nglesson.config(['$routeprovider', function ($routeprovider) { $routeprovider. when('/home', { templateurl: 'templates/content-container.html', controller: 'pages_contents' }). when('/about', { templateurl: 'templates/content-container.html', controller: 'pages_contents' }). otherwise({ templateurl: 'templates/something-else.html' }); }]);
i have basic template templates/content-container.html. not know parameters set within of it. 1 works: {{homepage.pagecontent}} of course of study homepage.
i tried different controller @ first, appeared had set different controllers in when() function in router. meaned different templates , kinf of stupid.
i cannot figure myself. there simple solution? can give me advices? give thanks much in advance!
you don't need different controllers it's suggested.
typically you'd create html template , augment angular dynamic content.
if have static content may include in template not in angular.
you can page.
nglesson.controller('about_contents', ['$scope', function ($scope) { $scope.aboutpage = { pageuri: 'about', pagename: 'about', pagedescription: 'bla bla bla', pagecontent: 'bla bla bla bla blabla' }; // , on... }]);
and add together controller router configuration , ng-controller="about_contents"
html
angularjs
No comments:
Post a Comment