1

i'm trying to accomplish something really nice (and really strange).

I've got an angular controller calling (with $http.get, passing arguments got from angular) a php script which gets some data from the database and decide to echo one out of two possible html templates.

The problem is, in those templates there are expressions which should be parsed by angular. They don't.

Here are the scripts:

the first angular controller:

    $http.get("../php/jwtCheck.php?token=" + localStorage.token + "&courseid=" + $stateParams.id).success(function (response) { 

       $scope.phpData = $sce.trustAsHtml(response);

    });

the receiving php script:

//doing mysql stuff
if (sqlStuff::isBought($row[bought], $stuffID)){
                include '../boughtTemplate.html';
            } else
            {
                include "../previewTemplate.html";
            }

inside the templates i have this call to angular $scope:

<video data-html5-video="{{generateVideoFolder($index)}}" data-controls="true" data-preload="false" data-width="400" data-height="224">
</video>

which never got parsed by angular.

Any idea?

5
  • Read Debugging AngularJS Apps Commented Nov 17, 2015 at 15:25
  • I'd check the responses of the php script and how Angular is receiving them first Commented Nov 17, 2015 at 15:28
  • @KhaledShaaban the $scope.phpData should be injected in the main template like this: <div ng-bind-html="phpData"> </div> but it doesn't Commented Nov 17, 2015 at 15:34
  • see This Answer , hope it helps you out somehow Commented Nov 17, 2015 at 15:42
  • @KhaledShaaban not really helping. I'm already using ngSanitize in the right way (just checked). The real problem is I have to make Angular parse an expression inside the content of a ngSanitized string. Commented Nov 17, 2015 at 15:59

1 Answer 1

1

You need to compile phpData.

Here is one approach I stole from another SO question: https://stackoverflow.com/a/29994559/3563439

See the solution applied to your case in my Fiddle: http://jsfiddle.net/masa671/zfftw7qr/

Sign up to request clarification or add additional context in comments.

1 Comment

really easy and really smart. Thank you a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.