Difference between ng-bind and interpolation {{}} in Angular

后端 未结 9 1357
独厮守ぢ
独厮守ぢ 2020-12-03 02:05

Is there any difference between {{ }} and ng-bind in angular.

I am quite new to Angular. I started with using {{ }} and then in the documentation i find ng-bind. I

9条回答
  •  Happy的楠姐
    2020-12-03 02:23

    Another difference is the way ng-bind and interpolation display the data. ng-bind calls the toString() method, whereas interpolation uses a custom "stringify" function.

    Example

    The current time is {{currentDateTime}}.

    The current time is .

    MyObject is {{myObject}}

    MyObject is


    Output

    The current time is "2017-11-18T15:09:59.429Z".
    
    The current time is Sat Nov 18 2017 10:09:59 GMT-0500 (EST).
    
    MyObject is {"key1":"value1","key2":"value2","key3":"value3"}
    
    MyObject is [object Object]
    

提交回复
热议问题