SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.link (http://127.0.0.1:8080/application/app.js:23:25)
at http://127.0.0.1:8080/node_modules/angular/angular.min.js:16:71
at http://127.0.0.1:8080/node_modules/angular/angular.min.js:83:480
at ta (http://127.0.0.1:8080/node_modules/angular/angular.min.js:84:35)
at n (http://127.0.0.1:8080/node_modules/angular/angular.min.js:69:226)
at http://127.0.0.1:8080/node_modules/angular/angular.min.js:79:323
at http://127.0.0.1:8080/node_modules/angular/angular.min.js:134:167
at m.$eval (http://127.0.0.1:8080/node_modules/angular/angular.min.js:148:47)
at m.$digest (http://127.0.0.1:8080/node_modules/angular/angular.min.js:145:92) <table-list list="{{searchList}}" class="ng-isolate-scope">
// app.js
var app = angular.module('myglamm', []);
//controller
app.controller('datalist', ['$scope', '$http', function($scope, $http) {
$http.get('json/data.json')
.then(function(response) {
$scope.searchList = response.data.appointments;
console.log($scope.searchList);
});
}]);
app.directive('tableList', function() {
return {
restrict: 'E',
scope: {
list: '@'
},
templateUrl: 'myTable.html',
link: function(scope, elem, attrs) {
scope.data = JSON.parse(scope.list);
console.log(scope.data);
}
};
});
我正在尝试使用指令隔离范围在表中显示数据。