2

I need to pass a dynamic param to an applet.

This is my controller:

'use strict';

    angular.module('jworkApp')
      .controller('AppletCtrl',['$scope', function (scope) {
              scope.base64 = "abcd";
}]);

This is my view, the parameter base64 is defined in the controller as "abcd"

<p>{{base64}}</p>
<APPLET>
  <PARAM name="text" value={{base64}} />
</APPLET>

When I run my page I see in the p tag the string 'abcd' , but the applet param's value it's simply "{{base64}}".

How could i fix it?

13
  • It would be helpful, if you'd show us the rest of your code. Commented Jan 7, 2014 at 13:59
  • ok I add the controller of the view Commented Jan 7, 2014 at 14:11
  • I see a few problems there... Please refer to my working solution below. Commented Jan 7, 2014 at 14:14
  • I can see in my applet the value "{{base64}}" as param. Commented Jan 7, 2014 at 14:23
  • Did you try looking at it through Chrome Dev Tools? It sure works on my setup... Commented Jan 7, 2014 at 14:24

2 Answers 2

6

I solved passing the entire applet declaration. In this way it works correctly.

Controller:

angular.module('jworkApp')
  .controller('AppletCtrl',['$scope', '$sce', function ($scope, $sce) {

            $scope.b64 = 'AAAA';
            $scope.applet = 
                "<APPLET>"+
                "<PARAM name=\"testo\" VALUE=\""+$scope.b64+"\" />"+
                "</APPLET>";

             $scope.getAppletCode = function() {
                  return $sce.trustAsHtml($scope.applet);
             };

  }]);

view:

<div ng-bind-html="getAppletCode()"></div>
Sign up to request clarification or add additional context in comments.

Comments

0

A working example might be:

<!doctype html>
<html ng-app = "app">
<head>
    <script src = "angular.min.js"> </script>
</head>

<div ng-controller = "Ctrl">
    <p>{{base64}}</p>
    <APPLET>
      <PARAM id = "applet"name="{{base64}}" value="{{base64}}" />
    </APPLET>

    <div id = "debug">

    </div>
</div>

<script>
    var app = angular.module('app', []);
    app.controller('Ctrl', ['$scope', function($scope) {
        $scope.base64 = "base-sixty-four";
    }]);


    //Code to prove, that indeed, the value is what you're looking for     
    var applet = document.getElementById('applet');
    document.getElementById('debug').innerHTML = applet.value;
</script>
</html>

One thing to note: since you can't see the changes on the webpage, the way to view the result is through some kind of Development Tools, such as Chrome Dev Tools, because the value has been changed by angular after the page has been loaded. This means, that simply viewing the source will not show desired results.

Comments

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.