【发布时间】:2016-09-09 18:54:15
【问题描述】:
我正在尝试在我的角度页面中解析 html 值,但不确定我做错了什么,我在控制台中收到此错误:
app.js:13 Uncaught SyntaxError: Unexpected token )
app.js
var App = angular.module('App', []);
App.controller('ProjectCtrl', function($scope, $http) {
$http.get('app/test.json')
.then(function(res){
$scope.projects = res.data;
});
App.filter('to_trusted', ['$sce', function($sce){
return function(text) {
return $sce.trustAsHtml(text);
};
});
test.json
[
{ "icon": "<i class="fa fa-github fa-3x" aria-hidden="true"></i>", "name": "lovelycss" },
{ "icon": "<i class="fa fa-github fa-3x" aria-hidden="true"></i>", "name": "lovely-icons" }
]
html:
<div ng-controller="ProjectCtrl">
<ul>
<li ng-repeat="project in projects">
<div ng-bind-html="'{{project.icon}}' | to_trusted"></div>- <em>{{project.name}}</em>
</li>
</ul>
</div>
我要归档的是:http://jsfiddle.net/JfGVE/1547/
我想要一个 json 加载图标和文本。
我希望现在这一切都清楚了。
【问题讨论】:
-
第 13 行是哪一行?