Skip to content

Instantly share code, notes, and snippets.

@hkusu hkusu/data.js Secret
Last active Jan 30, 2019

Embed
What would you like to do?
ゆめみスタッフブログ用のデモです。
'use strict';
angular.module('ngMockTestApp')
.factory('JsonData', function ($http) {
return {
getSampleData: function () {
return $http.get('data/sample.json?hoge=1')
.success(function(data, status, headers, config) {
return data;
});
}
}
})
;
<!-- 対応する Controller は app.js の $routeProvider で定義済み -->
<li ng-repeat="item in items">
{{item.id}} - {{item.name}}
</li>
'use strict';
angular.module('ngMockTestApp')
.controller('MainCtrl', ['$scope', 'JsonData', function ($scope, JsonData) {
JsonData.getSampleData().then(function(res){
$scope.items = res.data;
});
}])
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.