search

Home  >  Q&A  >  body text

html5 - angularjs video src属性不能和模型绑定?

<video ng-src="/uploadfile/upload/image/{{videosrc}}" controls="controls"></video>                             

当我把video换成img的时候,是能看到{{videosrc}}的值的

天蓬老师天蓬老师2770 days ago558

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 11:54:58

    <video ng-src="trustSrc(videosrc)" controls="controls"></video>   
    //controller 依赖 $scope, $sce
    $scope.trustSrc = function(url){
        return $sce.trustAsResourceUrl(url);
    }

    Reference: https://code.angularjs.org/1.4.6/docs/api/ng/service/$sce

    reply
    0
  • 黄舟

    黄舟2017-04-17 11:54:58

    There can be no redundant paths in src and it will be ok, <video ng-src="{{videosrc}}"></video>

    reply
    0
  • Cancelreply