ng-view not working with partials in AngularJS/Express

后端 未结 3 834
忘掉有多难
忘掉有多难 2021-01-19 00:14

Everything was working until I tried to display a partial file in ng-view.

/public/app/app.js

angular.module(\'app\', [\'ngResource\         


        
3条回答
  •  生来不讨喜
    2021-01-19 01:08

    Thers is something off in your app.js file. Replace it with this and you should be good to go:

    var app = angular.module('app', ['ngResource', 'ngRoute']);
    
    angular.module('app').config(function($routeProvider, $locationProvider){  
        $locationProvider.html5Mode(true);
        $routeProvider
            .when('/', { templateUrl: '/partials/main', controller: 'mainCtrl'});
    });
    
    
    angular.module('app').controller('mainCtrl', function($scope){  
        $scope.myVar = "Hello Angular";
    });
    

提交回复
热议问题