service - AngularJS update view after $resource remove() -


i having trouble updating view after $resource remove(). element get's removed, can see change after refreshing page.

controller

this.getdata = function() {   var query = someservice.query()   query.$promise.then(function(res) {     this.data = res; // gets data view   }.bind(this)); }  this.removedata = function(id) {   var query = someservice.remove({data_id: id})    query.$promise.then(function(res) {      this.getdata() // makes request doesn't update view      console.log(this.data) // returns data, removed element    }.bind(this)) } 

factory

.factory('someservice', ['api_url', '$resource', function (api_url, $resource) {   return $resource(api_url + '/data', null, {     create: {method: 'post'},     update: {method: 'put'}, }); 

any idea missing?

ok, i've found culprit..

using ngdialog , apparently, creating 2 different instances of same controller assigning same controlleras dialog. like:

ngdialog.openconfirm({   controller: 'parentctrl',   controlleras 'vm',   template: '<span ng-click="vm.removefeed(id)></span>' }) 

the fix pass scope object dialog: not creating instance of controller, instead, uses parent/external one, updating view on $resource remove().

ngdialog.openconfirm({   scope: $scope,   template: '<span ng-click="vm.removefeed(id)></span>' }) 

however, seems fix now, giving me no choice inject $scope parent controller this.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -