如何从$ scope angularjs中删除$ sce对象

时间:2015-05-17 19:18:21

标签: angularjs angularjs-scope

如果我有$scope

$scope.Pages = [
            $sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" onclick="DeletePage()">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>'),
            $sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" ng-click="DeletePage($index)">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>')
        ];

如何删除

的对象
$sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" ng-click="DeletePage($index)">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>')

表单$scope.Pages 我也想访问

的索引
$sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" ng-click="DeletePage($index)">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>')

HTML

中的ng-repeat

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
var VisualEditor = angular.module("VisualEditor", ["ngSanitize"]);
			VisualEditor.controller('VisualEditorController', function($scope, $sce) {
    		$scope.Pages = [
    			$sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" onclick="DeletePage($index)">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>'),
    			$sce.trustAsHtml('<div class="col-sm-12" style="height:3vh;background-color:#adb5b9;"><a class="DeletePage" ng-click="DeletePage($index)">x</a></div><div class="col-sm-12 Text"><p class="Paragraph" contenteditable="true">Write Your Text Here</p></div>')
    		];
    		$scope.DeletePage = function(index){
				$scope.Pages.splice(index, 1);
			}
});
&#13;
<div class="row" ng-repeat="pg in Pages track by $index">
						<div class="SinglePage" ng-bind-html="pg">
						</div>
					</div>
&#13;
&#13;
&#13;