ionic 项目中,video标签添加ng-src报错(
1、添加过滤器,以及常见过滤器
//向网页中添加html代码,需要被信任
mpFilters.filter('to_trustHtml', ['$sce', function ($sce) { return function (text) { return $sce.trustAsHtml(text); } }]); //向网页中展示地址,需要被信任 mpFilters.filter('to_trusted', ['$sce', function ($sce) { return function (text) { return $sce.trustAsResourceUrl(text); } }]); //大小写转化 mpFilters.filter('titleCase', [function () { var titleCaseFilter = function (input) { var words = input.split(' '); for (var i = 0; i < words.length; i++) { words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1); } return words.join(' '); }; return titleCaseFilter; }]); //日期格式化 mpFilters.filter('dateTranfer', [function () { var dateCaseFilter = function (input) { var inputDate = new Date(input); var month = inputDate.getMonth() + 1; var words = inputDate.getFullYear() + '年' + month + '月' + inputDate.getDate() + '日' + '星期' + '日一二三四五六'.charAt(inputDate.getDay()) + '<br/><br/>'; return words; }; return dateCaseFilter; }]);
2、在网页中需要使用过滤器的,直接使用即可
1 <video style="bottom:50px;background-color:black;" poster="http://www.xxx.com/1.jpg" ng-show="showVideo" width="100%" height="85%" ng-repeat="v in arrayVideo track by $index" ng-click="openLink('{{v}}');" controls="controls" ng-src="{{v| to_trusted}}" webkit-playsinline="true"> 2 </video>