Sunday, 15 August 2010

grails - angularJS $routeProvider -



grails - angularJS $routeProvider -

i using angularjs in grails application. before that, tried sample internet. tried utilize angularjs $routeprovider partial views in main view. workflows follows:

my main view index.gsp:

<!doctype html> <html lang="en"> <head> <title>angularjs routing example</title> </head> <body ng-app="routeapplication"> <div class="container"> <div class="row"> <div class="col-md-3"> <ul class="nav"> <li><a href="#addneworder"> add together </a></li> <li><a href="#showorders"> show </a></li> </ul> </div> <div class="col-md-9"> <div ng-view></div> </div> </div> </div> <script src="js/angular.js"></script> <script src="js/angular-route.js"></script> <script src="js/app.js"></script> </body> </html>

my partial views are: add_order.gsp , show_orders.gsp show sample message each view.

my app.js follows:

var sampleapp = angular.module('routeapplication', ['ngroute']); sampleapp.config(['$routeprovider', function($routeprovider) { var base of operations = '${request.contextpath}'; $routeprovider. when('/addneworder', { templateurl: 'templates/add_order.html', controller: 'addordercontroller' }). when('/showorders', { templateurl: 'templates/show_orders.gsp', controller: 'showorderscontroller' }). otherwise({ redirectto: '/addneworder' }); }]); sampleapp.controller('addordercontroller', function($scope) { $scope.message = 'this add together new order screen'; }); sampleapp.controller('showorderscontroller', function($scope) { $scope.message = 'this show orders screen'; });

note: created templates folder , placed parital views on that.

this problem that, whenever click load partial views shows

`http://localhost/angularjsrouting/templates/show_orders.gsp` 404 not found

am missing or there problem of placing partial views?

i don't think work. since templateurl templates/show_orders.gsp angularjs seek find file within templates folder in webapp.

angularjs grails

No comments:

Post a Comment