【发布时间】:2014-09-16 23:40:36
【问题描述】:
这是控制器中的工作代码PLUNKER
public JsonResult videohome()
{
BaseController bc = new BaseController();
var video = (from n in bc.db.Video where n.Video == true select n).FirstOrDefault();
var videos = new Videohome { youtubeid = "//www.youtube.com/embed/" + video.youtubeid };
return Json(videos, JsonRequestBehavior.AllowGet);
}
public class Videohome
{
public string youtubeid { get; set; }
}
它给出的输出为 {"youtubeid":"//www.youtube.com/embed/_kux-YQujjM"}
但是当我将此输出加载到我的脚本中时,它会显示错误,
<script>
countryApp.controller('Homevideo', ['$scope', "$http",'$sce', function (scope, sce, http) {
http.get('@Url.Content("/sample/videohome")').success(function (data) {
$scope.video = data;
$scope.videoUrl = $sce.trustAsResourceUrl($scope.video + $scope.video.youtubeid);
});
}]);
</script>
<div ng-controller="Homevideo" > <br />
<iframe width="100%" height="250" ng-src="{{videoUrl}}" frameborder="0" allowfullscreen=""></iframe>
<p>{{videoUrl}}</p>
</div>
我是否遗漏了代码中的任何内容,不胜感激。
【问题讨论】:
-
您确定将 angular.js 附加到您的应用程序吗?
标签: javascript jquery angularjs youtube angularjs-directive