Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Here is working code PLUNKER in the controller

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; }
        }

It gives the ouptput as {"youtubeid":"//www.youtube.com/embed/_kux-YQujjM"}

But when i load this output into my script it displays error,

<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>

Did i missed anything in my code, Any help is appreciated.

share|improve this question
    
you sure what you attached angular.js to your app ? – Narek Mamikonyan Jul 25 '14 at 7:51
up vote 1 down vote accepted

here is a working version (without the http): http://plnkr.co/edit/6M0qdSNlUe1f7mhT7ASt?p=preview I spotted few errors, first, try to organize the import in the same order and with a '$' prefix :

countryApp.controller('Homevideo', ['$scope', "$http",'$sce', function ($scope, $http, $sce)

The second thing I noticed is $scope.video + $scope.video.youtubeid I think you're not doing it right and $sce.trustAsResourceUrl($scope.video.youtubeid); should be enough as $scope.video is an json array it has nothing to do with the url.

share|improve this answer
    
Excellent, Thanks This code helps for my issue... :) – KesaVan Jul 25 '14 at 10:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.