ng-view

ng-view 是一个与 $route 一起使用的指令,用于在主页面布局中呈现局部视图。在这个例子中,Index.html 是我们的主文件,当用户登陆“/”路线时,templateURL home.html 将在 Index.html 中呈现,其中提到了 ng-view

angular.module('ngApp', ['ngRoute'])

.config(function($routeProvider){
  $routeProvider.when("/",
    {
      templateUrl: "home.html",
      controller: "homeCtrl"
    }
  );
});

angular.module('ngApp').controller('homeCtrl',['$scope', function($scope) {
  $scope.welcome= "Welcome to stackoverflow!";
}]);

//Index.html
<body ng-app="ngApp">
    <div ng-view></div>
</body>

//Home Template URL or home.html
<div><h2>{{welcome}}</h2></div>