AngularJS directive dynamic templates

前端 未结 4 1589
悲&欢浪女
悲&欢浪女 2020-12-04 08:06

I\'m trying to make directive with differtent templates based on scope value.

This is what i done so far which i don\'t know why doesn\'t work http://jsbin.com/mibey

4条回答
  •  我在风中等你
    2020-12-04 08:54

    1) You are passing content as attribute in your html. Try this:

    element.html(getTemplate(attrs.content)).show();
    

    instead of:

    element.html(getTemplate(scope.content)).show();
    

    2) data part of directive is getting compiled so you should use something else. Instead of data-type, e.g. datan-type.

    Here is the link:

    http://jsbin.com/mibeyotu/6/edit

提交回复
热议问题