javascript - Strange behavior angularjs returning "TypeError: Cannot assign to read only property" -


i'm facing strange behavior angularjs.

.factory('configservice', function($http){     var base = 'http://harold:pituca521zkjoidksjdiiqudjsdh120@localhost:3000/configuration/';      var getconfig = function(){         return $http.get(base + 'config');     };      var setconfig = function(config){         return $http.post(base + 'update', config);     };      return {         getconfig: getconfig,         setconfig: setconfig     }; }) .controller('configurationcontroller', function($scope, $http, $window, configservice){      $scope.config = {};     configservice.getconfig()         .success(function(data, status, headers, config){             console.log(data);             $scope.config = data;         });       $scope.saveconfiguration = function(config){         configservice.getconfig(config)             .success(function(data, status, headers, config){                 $window.location.reload();             });     }; }); 

when console.log(data) getting url instead of object localhost never hit.

/users/rodrigoqueirolo/desktop/factory/public/index.html  

i think problem because of url credentials surprisingly have other 6 routes doing same thing(crud). here full error when click on input form.

typeerror: cannot assign read property 'daily_cota_premium_user' of /users/user/desktop/factory/public/index.html     @ oa (file://localhost/users/user/desktop/final/admin/angular.min.js:102:253)     @ function.d.assign (file://localhost/users/user/desktop/final/admin/angular.min.js:104:22)     @ o (file://localhost/users/user/desktop/final/admin/angular.min.js:210:465)     @ $$writemodeltoscope (file://localhost/users/user/desktop/final/admin/angular.min.js:215:271)     @ file://localhost/users/user/desktop/final/admin/angular.min.js:215:209     @ k (file://localhost/users/user/desktop/final/admin/angular.min.js:213:285)     @ g (file://localhost/users/user/desktop/final/admin/angular.min.js:213:215)     @ $$runvalidators (file://localhost/users/user/desktop/final/admin/angular.min.js:213:499)     @ $$parseandvalidate (file://localhost/users/user/desktop/fina/admin/angular.min.js:215:130)     @ $commitviewvalue (file://localhost/users/user/desktop/final/admin/angular.min.js:214:272)  

thanks

i'm not javascript expert, here's take:

change return of service return function runs function (odd sounding)

.factory('configservice', function($http){     ...      return {         getconfig: function(){             return getconfig();         },          setconfig: function(config){             return setconfig(config);         }     }; }) 

this should return promise can use.

but maybe i'm wrong, looking @ code, should ask.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -