在角

2015-11-06 41 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进行复杂的路由操作。