I'm creating a directive in AngularJs. Directive will receive from app controller a JSON object and based on that the directive will display the content.
I made a simple demo based on my problem that can be found at: http://jsfiddle.net/darkyndy/6StLm/
Now my JSON looks something like:
ctrlItemJson = {
myk: "something",
state: {
step: 1.0
}
};
Why in directive-link, controller and view when I'm accessing state.step I get 1 instead of 1.0 ?
Setting value as string '1.0' it works, but for me I need to be exactly the same way how it was sent by the controller.
Later edit:
This is mainly from Javascript as if you try
var a = 1.0 and then try console.log(a) you will see 1
In this case for my issue I will discuss with API guys to send strings...
Solution:
1. In case you cannot control value:
For where you want to keep decimals (decimals are zeros, eg: 1.0, 2.00) instead of using floats then use Strings (eg: '1.0', '2.00').
2. In case you can control and know precision (directive will decide precision):
Then check responses for this question. Example: http://jsfiddle.net/SE5s3/