javascript - AngularJS add Action to Controller -
i've been using other mvc frameworks i'm new angularjs , have ran issue. have controller called "projects" , route /projects want able /projects/java call new page template/view , display content.
how in angularjs? there way create actions projects or have else?
angular .module('konradapp', [ 'ngroute' ]) .config(function ($routeprovider) { $routeprovider .when('/', { title : 'welcome', templateurl : 'views/main.html', controller : 'mainctrl', controlleras : 'main' }) .when('/about', { title : 'about', templateurl : 'views/about.html', controller : 'aboutctrl', controlleras : 'about' }) .when('/projects', { title : 'projects', templateurl : 'views/projects.html', controller : 'projectsctrl', controlleras : 'projects' }) .when('/contact', { title : 'contact', templateurl : 'views/contact.html', controller : 'contactctrl', controlleras : 'contact' }) .otherwise({ redirectto : '/' }); }); controller:
angular.module('konradapp') .controller('projectsctrl', function () { });
what you're after way add nested views. refer ui-router docs on how that: https://github.com/angular-ui/ui-router/wiki/nested-states-%26-nested-views
the idea add nested ui-view in projects.html , add child route sub-view.
Comments
Post a Comment