What is the difference between the $parse, $interpolate and $compile services?

前端 未结 3 1058
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 16:03

What is the difference between $parse, $interpolate and $compile services? For me they all do the same thing: take template and compil

3条回答
  •  离开以前
    2020-11-30 16:59

    Here is the cute explanation.

    var img = img/{{name}}.{{extension}}
    
    $parse - > (name,extension) = > vimal , .jpg
    $interpolate -> use angular $parse and convert into string -> img/vimal.jpg
    $compile -> can turn html string img/vimal.jpg into live DOM so new img tag will be added inside our DOM with all prototype that a img tag have.
    

提交回复
热议问题