0

I wonder why my template which I refer to in my angular state ('home') won't be shown - in my index.html I included a <ui-view></ui-view> tag. Does anyone know?

app.js:

var app = angular.module('portfolio', ['ui.router']);

html:

<body ng-app="portfolio">
    <p>hellooooo</p>
    <ui-view></ui-view>

    <script src="angular.min.js"></script>         
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/1.0.0-beta.2/angular-ui-router.js"></script>
    <script src="js/app.js"></script>
    <script src="js/home/home.js"></script>     
</body>

home.js:

app.config(function ($stateProvider) {
    $stateProvider.state('home', {
        url: '/',
        templateUrl: '/browser/js/home/home.html'
    });
});

home.html:

<div><p>not working</p></div>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
javascript2016
  • 973
  • 3
  • 17
  • 41

1 Answers1

1

I think your router are not able to match / url. That's why you have to specify a default state, because not always your url will come with /.

Consider forcing a default state like so:

$stateProvider.otherwise('/');
lenilsondc
  • 9,590
  • 2
  • 25
  • 40