angularjs - trouble with angular and flask - error message vauge -
not able angular read in object fetched via service. error message in brower vauge, doesn't reference of code lines. checked via chrome developer tools , api call getting made. ideas?
error message:
typeerror: undefined not function @ copy (http://127.0.0.1:5000/static/lib/angular/angular.js:593:21) @ http://127.0.0.1:5000/static/lib/angular/angular-resource.js:410:19 @ wrappedcallback (http://127.0.0.1:5000/static/lib/angular/angular.js:6846:59) @ http://127.0.0.1:5000/static/lib/angular/angular.js:6883:26 @ object.scope.$eval (http://127.0.0.1:5000/static/lib/angular/angular.js:8057:28) @ object.scope.$digest (http://127.0.0.1:5000/static/lib/angular/angular.js:7922:25) @ object.scope.$apply (http://127.0.0.1:5000/static/lib/angular/angular.js:8143:24) @ done (http://127.0.0.1:5000/static/lib/angular/angular.js:9170:20) @ completerequest (http://127.0.0.1:5000/static/lib/angular/angular.js:9333:7) @ xmlhttprequest.xhr.onreadystatechange (http://127.0.0.1:5000/static/lib/angular/angular.js:9303:11)
service:
angular.module('angularflaskservices', ['ngresource']) .factory('pic', function($resource) { return $resource('/api/pic/:picid', {}, { query: { method: 'get', params: { picid: '' }, isarray: true } }); }) ;
angular controller:
function profilecontroller($scope, pic) { var picsquery = pic.get(function(pics) { $scope.pics = pics; }); }
flask view:
@app.route('/api/pic/') def on_recent(): if not session.has_key('access_token'): return 'missing access token' try: api = client.instagramapi(access_token=session['access_token']) recent_media, next = api.user_recent_media() print recent_media photos = [] media in recent_media: if (media.type != "video"): photos.append({"picid": 1, "url": media.get_low_resolution_url()}) except exception e: print(e) return json.dumps(photos)
your service code looks not sure if have of dependencies injected properly.
var app = angular.module('myapp', ['angularflaskservices']); app.controller('profilecontroller', [ '$scope', 'pic', function($scope, pic) { var picsquery = pic.get(function(pics) { $scope.pics = pics; }); }]);
Comments
Post a Comment