compile
ここでは関数は必要ありません。これは機能します:
var myAppModule = angular.module('myApp', []);
myAppModule.controller('TextController',
function($scope) {
$scope.userModel = [{id:'1',name:'user1'},{id:'2',name:'user2'},{id:'3',name:'user3'}];
});
myAppModule.directive('formModal', ['$http', '$compile', function($http, $compile) {
return {
scope: {
formObject: '='
},
link: function(scope, element, attrs){
var template, $element, loader;
loader = $http.get('modal.html')
.success(function(data) {
template = data;
});
loader.then(function() {
$element = angular.element($compile(template)(scope));
});
scope.close = function() {
$element.modal('hide');
};
element.on('click', function(e) {
e.preventDefault();
$element.modal('show');
});
}
}
}]);