angularjs如何从编译html中获取控制器?

时间:2015-12-15 07:53:25

标签: javascript angularjs compilation controller

我使用$ http服务来获取html并通过angular编译它 我想在编译范围内获得控制器

这是我的代码

<!-- language-all: lang-javascript -->

var viewUrl = "/views/configWindow.html";
var that = this;
this.$http.get(url, {}).success(function(response) {
    var content = (response);
    var el = angular.element(document.getElementById('modalWindow'));
    el.html(content);
    //compile html for angular
    that.$compile(el.contents())(that.$rootScope.$new(true, that.$rootScope));


    //I want to get configController in here for init some data
    var configController = ? ? ?
});

file configWindow.html

<!-- language-all: lang-html -->
<div class="form-horizontal col-md-10" ng-controller="ConfigController as configCtrl"> 
<h2>{{configCtrl.Title}}</h2>
     ...
<div>

0 个答案:

没有答案