【发布时间】:2014-05-13 02:30:45
【问题描述】:
我有以下指令
app.directive('myPage', function() {
return {
restrict: 'E',
templateUrl: app.urlBuilder('about')
}
})
默认会加载该指令
为了切换标签,我已经加载了多个页面作为标签内容,为此我使用了 $http 服务。
这是我的html
<my-page></my-page>
<div>{{datas}}</div>
我的控制器
app.controller('PageController', ['$scope', '$http', 'PageService', function($scope, $http, PageService) {
$scope.changePanel = function(url) {
PageService.getPageTemplate(url).success(function(data) {
$scope.datas = data;
})
}
}])
问题最初是用 about.html 加载的,而 changePanel 是单击事件,而单击事件发生时,将加载并创建新页面 $scope 并在模板中用作{{datas}}。 现在加载数据后,我可以删除 <my-page></my-page> 内容吗?
【问题讨论】:
标签: angularjs angularjs-directive angularjs-scope