简体   繁体   English

Angular JS路由不起作用

[英]Angular js routing not working

I am trying to setup simple angular routing with my Laravel application 我正在尝试使用Laravel应用程序设置简单的角度路由

import Angular from 'angular';
import Route from  'angular-route';
var route = Angular.module("main",[Route]);


route.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
    when('/test', {
        templateUrl: 'app/test.html',
        activetab:'emp',
        controller:'WelcomeController'
    })
}]);

route.controller('WelcomeController',function ($scope) {
    alert('ok');
})

HTML HTML

<body ng-app="main" >

    <a href="#test">test</a>

</body>

When i click on the link i got nothing in browser there is no error present in console 当我单击链接时,浏览器中没有任何内容,控制台中没有错误

Here is the url obtained when cliked on the link 这是链接上的点赞后获得的网址

http://localhost:8000/#!#test

UPDATE UPDATE

Finally my routes works fine when i change to div 最后,当我更改为div时,我的路线可以正常运行

 <div id="main">
    <a href="#test">test</a>

     </div>

but the template file is not loading 但模板文件未加载

Change 更改

From

var route = Angular.module("main",[Route]);

To

var route = Angular.module("main",['ngRoute']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM