1

I have array like this:

vm.array = ['214','2912','82'];

I use map convert to int but not work

vm.newar = vm.array.map(Number); 

I render in html but nothing in newar

{{vm.newar}}

Where my wrong. Pls help me

Here is demo https://plnkr.co/edit/sgJaW3KgknBlg7egjQ2m?p=preview

5
  • it's correct.I think you have problem in define controllerAs syntax. Commented Apr 15, 2017 at 4:29
  • When i display {{vm.array}} it working fine , but new ar is nothing Commented Apr 15, 2017 at 4:31
  • please create a demo. Commented Apr 15, 2017 at 4:33
  • plnkr.co/edit/sgJaW3KgknBlg7egjQ2m?p=preview @HadiJeddizahed here my demo Commented Apr 15, 2017 at 4:38
  • please see this plnkr.co/edit/IRYdm9mmXTNwvHgPoDg8?p=preview Commented Apr 15, 2017 at 5:21

1 Answer 1

1

I change your business to get data as this. so you can use parseInt function for convert string to integer .

changes in services.js

function get(){
    return  $http.get('test.php').then(function(response){
         angular.forEach(response.data,function(d){
              arr.push({masp:d.masp,tensp:d.tensp,gia:d.gia});
               money.push(parseInt(d.gia));
        })
     return response.data; 
    })
} 

Demo

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.