@{
Layout = null;
} <!DOCTYPE html> <html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index6</title>
<script type="text/javascript" src="~/Scripts/angular.js"></script>
<script src="~/Scripts/angular-sanitize.js"></script>
</head>
<body>
<div ng-app="myApp">
<div ng-controller="firstController">
<div ng-bind="text">ng-bind只能繫結一個</div>
<div ng-bind-template="{{text}}{{name}}">ng-bind-template可以繫結多個</div>
<div ng-bind-html="h2">ng-bind-html 依賴sanitize外掛依賴ngSanitize也可以通過使用$sce服務</div>
<div ng-bind-html="detailContent()"></div>
<div ng-repeat="innerList in list" ng-init="outerIndex=$index">
<div ng-repeat="value in innerList" ng-init="innerIndex=$index">
<span>list[{{outerIndex}}][[{{innerIndex}}]]={{value}}; </span> </div>
</div>
<div>
<input type="text" ng-model="name" ng-model-options="{updateOn:'blur'}" />
{{name}} </div>
</div>
</div>
<script type="text/javascript">
var app = angular.module("myApp", ['ngSanitize']);
app.controller("firstController", function ($scope,$sce) {
$scope.text = "PhoneGap中文網";
$scope.name = "張三";
$scope.h2 = "<h2>這是H2</h2>";
$scope.detailContent = function () {
return $sce.trustAsHtml("<H1>使用ng的$sce來解析HTML</H1>");//記得寫return
};
$scope.list = [['a','b'],['c','d']];
}); </script>
</body>
</html>