我正在尝试按需设置textAngular,即何时和如果我需要它。如果文件中有下面的html,textAngular应用程序就能工作。
<body>
<div ng-app="textAngularTest" ng-controller="wysiwygeditor" class="container app">
<div text-angular="text-angular" name="htmlcontent" ng-model="htmlcontent" ta-disabled='disabled'></div>
</div>
</body>和js函数
angular.module("textAngularTest", ['textAngular']).controller('wysiwygeditor', function wysiwygeditor($scope) {
$scope.orightml = '<h2>Try me!</h2>';
$scope.htmlcontent = $scope.orightml;
$scope.disabled = false;
});为此,我将从html中删除ng-app指令,并将其封装在函数中,并使用引导程序来启动.
function apply(){
var app= angular.module("textAngularTest", ['textAngular']);
app.controller('wysiwygeditor', function wysiwygeditor($scope) {
$scope.orightml = '<h2>Try me!</h2>';
$scope.htmlcontent = $scope.orightml;
$scope.disabled = false;
});
angular.bootstrap(document, ["textAngularTest"]);
}不幸的是,这不起作用,有什么建议吗?
Codepen http://codepen.io/ambrosedheffernan/pen/vNEapL
发布于 2015-09-04 23:55:12
条件引导可能不是最优雅的解决方案,但在非SPA情况下,它可能有效。是的,它可以正常工作
http://codepen.io/anon/pen/dYPqYO
删除ng-app和
angular.bootstrap(document, ["textAngularTest"]);已添加。
https://stackoverflow.com/questions/32407065
复制相似问题