AngularJS - simple routing not working -
i have route parameter this
var app = angular.module("myapp", ["ngroute"]); app.config(['$routeprovider', '$locationprovider', function ($routeprovider, $locationprovider) { $locationprovider.hashprefix("!").html5mode(true); $routeprovider .when('/sukien', { templateurl: '/app/views/sukien/index.html' , controller: 'eventctrl' }) .when('/sukien/:id', { templateurl: function (params) { homecoming '/app/views/sukien/index.html?id=' + params.id }, controller: 'eventctrl' }) }])
why /sukien works , /sukien/:id doesn't ? indeed, angularjs seems not understand is. "uncaught typeerror: undefined not function"
/sukien/333 => failed work.
you mixing template url, state of application , search parameters seems.
the templateurl tells angularjs html file : unlikely depend on params.id , set via function, rather constant.
it has nil see url user sees in browser.
for illustration : '/app/views/sukien/suiken.html'
the url user sees :
.../suiken/1223445
and can access id in controller via $routeparams.id
angularjs
No comments:
Post a Comment