简体   繁体   中英

angular template src variable not working

videoSrc variable not evaluating properly

images/{{videoSrc}}.mp4 

if i'm writing only videoSrc then its working propely but while concating with other string it is not working

see jsfiddle

是的,在video插入srcng-src似乎已损坏,每当videoSrc更改时, videoSrc在指令的链接函数中手动创建元素。

You can use template: fn way see example bellow

angular.module('myApp', []).directive('videoPopup', function() {
    return {
        strict: 'A',
        scope: {
            videoSrc: '@'
        },
        replace:true,
        template: function(tElem, tAttrs){
            return '<video width="100%" controls><source 
src="images/'+tAttrs.videoSrc+'.mp4" type="video/mp4"><source src="images/'+tAttrs.videoSrc+'.webm" type="video/webm"></video>'

        } 
    }
});

working fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM