从模板编译后,是否可以动态关联控制器?
//Controller /path/ctrl/MainCtrl.js
angular.module('app')
.controller('MainCtrl', function () {
});
//Directive /path/dir/myDir.js
function link(scope, element, attrs) {
$templateRequest('path/oneTpl.tpl').then(function (html) {
$compile(element.html(html).contents())(scope);
//How can I do to dynamically inject MainCtrl into the oneTpl.tpl template using the path (/path/ctrl/MainCtrl.js)?
});
}