Angularjs ng-view does not work

The problem is incorrect usage of ng-app. Only declare ng-app once for your application, usually on the html element.

Then declare other modules as dependencies of your main module.

I put the ng-app declaration on the html tag and put your ng-routing in the app module, getting rid of the views module.

http://plnkr.co/edit/btL2QMyHxhDLH7cxZ1YV

var app = angular.module('app', ['ngRoute']);
app.config(function($routeProvider, $locationProvider){
    $routeProvider.
        when('/developers', {templateUrl: 'dev.html', controller: 'DevCtrl'}).
        when('/designers',{templateUrl: 'design.html',controller: 'DesignCtrl'}).
        otherwise({ redirectTo: '/index' });
    // $locationProvider.html5Mode(true);
});

<html ng-app="app">

You can also put the view-logic in a separate module, but usually you will then also put it in a different file.

The html5mode is disabled because it triggered an error (it’s a little bit tricky to make that work).

Note: it actually is possible to use multiple ng-app by manually bootstrapping them, but you really shouldn’t do this unless you have a very good reason for it.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)