在角

2015-11-06 34 views
0

加載路由的路由中我有些HTML看起來像這樣:在角

<body ng-controller="main"> 
    <div id="main"> 
     <div ng-view></div> 
    </div> 
</body> 

這裏是控制器:

var app = angular.module('buildson', ['ngRoute', 'ngAnimate']); 

app.controller('main', function($scope) { 
    $scope.$on("$routeChangeSuccess", function (event, currentRoute, previousRoute) { 
     window.scrollTo(0, 0); 
    }); 
}); 

這裏是路由:

//ROUTING 
app.config(function($routeProvider) { 
    $routeProvider 
     .when('/', { 
      templateUrl : 'home.html' 
     }) 
     .when('/courses', { 
      templateUrl : 'views/coursesTeaching.html' 
     }); 
}); 

Here is coursesTeaching.html

<div class="coursesList"> 
    [Display a list of courses here] 
    <a href="#">Display Documentation</a> 
</div> 

這裏是documentationWidget.html

Documentation Content is in this file 

當他們點擊此鏈接<a href="#">Display Documentation</a>它加載documentationWidget.html內容到<div class="documentationWidget"></div>點上我想要做的是,我想這是一個在視圖或子路徑中查看。我不能用jQuery Ajax或任何東西來做,因爲我希望能夠在加載的html文件中使用Angular變量。

+0

基本上你需要切換到'UI-router',你會發現ngRoute之間'的區別'&'ui-router'在這裏http://stackoverflow.com/a/27645346/2435473 –

回答

0

我被告知應該使用第三方庫ui-router進行復雜的路由操作。