0

I am trying to setup simple angular routing with my Laravel application

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

<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

Finally my routes works fine when i change to div

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

     </div>

but the template file is not loading

14
  • Change <a href="#test">test</a> to <a href="/test">test</a>, and retry. Commented Jun 3, 2017 at 6:35
  • @31piy it conflicts with laravel routes Commented Jun 3, 2017 at 6:53
  • what's the error? Commented Jun 3, 2017 at 7:29
  • No error is shown that makes me annoying:) Commented Jun 3, 2017 at 7:30
  • template file location public/app/test.html and js file is in public/app/js Commented Jun 3, 2017 at 7:31

1 Answer 1

0

Change

From

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

To

var route = Angular.module("main",['ngRoute']);
Sign up to request clarification or add additional context in comments.

5 Comments

Nop still the same error,i am using webpack to build the files
When i hide import 'angular-route' i got route not defined error
Try changing your template <header> <h1>My app</h1> <ul> <a href="#test">test</a> </ul> </header> <div class="content"> <div ng-view></div> </div>
could you more specific??
change your html as mentioned above

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.