Javascript 指令中带有ng include的jQuery组件
我在angular中使用jQuery组件,其指令如下:Javascript 指令中带有ng include的jQuery组件,javascript,jquery,angularjs,angularjs-directive,angularjs-ng-include,Javascript,Jquery,Angularjs,Angularjs Directive,Angularjs Ng Include,我在angular中使用jQuery组件,其指令如下: angular.module('directives.flavr', []) .directive('flavr', function () { return { restrict: 'E', scope: true, link: function (scope, element, attrs) { elemen
angular.module('directives.flavr', [])
.directive('flavr', function () {
return {
restrict: 'E',
scope: true,
link: function (scope, element, attrs) {
element.bind('click', function () {
new $.flavr({
title: 'Form',
content: 'HTML form example',
dialog: 'form',
form: {content: '<div ng-include="directives/flavr/templates/loginForm.tpl.html"></div>', method: 'post'},
onSubmit: function ($container, $form) {
alert($form.serialize());
return false;
}
});
});
}
};
});
<flavr html="/* I want to put a templatecache url and be able to load it when the popup is open */"></flavr>
有什么想法吗?可能是'ng transclude'在这种情况下会对您有所帮助。您可以在指令中为
templateUrl
使用templateCache或脚本标记模板。如果两者都没有找到,那么它将向服务器上的相同路径发出ajax请求。我认为使用jquery组件来显示角度html不是一个好主意。如果您只想显示静态html文本,那么只需从teplateCache manyally$templateCache.get(attrs.html)加载它