angularjs - Why does not wotk routeProvider in Angular JS? -
i use routeprovider in angular js:
.when('/chat/dialog/:id', { controller: 'chatcontroller' });
in controller have:
if($routeparams.id) { alert('ok'); }
and url looks as:
http://site-dev.com/chat/dialog/1
link is: <a href="/chat/dialog/1"></a>
why not work routing in angular js?
controller:
.controller('chatcontroller', ['$scope', '$sce', '$http', '$location', '$anchorscroll', '$timeout', '$routeparams', function ($scope, $sce, $http, $location, $anchorscroll, $timeout, $routeparams, ) { if($routeparams.id) { alert('ok'); } }])
routing:
.config(function ($locationprovider, $routeprovider) { $routeprovider .when('/profile/personal/:type', { templateurl: '/public/html/personal.html', controller: 'editprofilecontroller' }) /* chat */ .when('/chat/dialog/:id', { controller: 'chatcontroller' }); })
try add head
tag <base href="/">
, this:
<head> <base href="/"> </head>
Comments
Post a Comment