Although combining Angular.js and Kendo UI is really easy, there is one thing that bit me in the food when I first started combining the two.
Let’s have a look at some code I wrote:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="editor-field"> | |
<input kendo-numerictextbox k-format="c2" ng-model="product.unitPrice" /> | |
</div> |
And then have a look at this code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="editor-field"> | |
<input kendo-numerictextbox k-format="'c2'" ng-model="product.unitPrice" /> | |
</div> |
Do you see the difference?
If you look carefully you should notice that the string ‘c2’ (to format the number as a currency) is quoted inside the attribute values. Without the single inside they will be interpreted as variable names and Angular-Kendo will look for $scope.c2.
Luckily Angular-Kendo will emit a warning in the JS console when such variables are not found.