本文介绍了使用 angularJS 绑定小程序参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将动态参数传递给小程序.
这是我的控制器:
'use strict';angular.module('jworkApp').controller('AppletCtrl',['$scope', function (scope) {scope.base64 = "abcd";}]);
这是我的看法,参数base64在控制器中定义为abcd"
{{base64}}
<小程序><PARAM name="text" value={{base64}}/></小程序>
当我运行我的页面时,我在 p 标签中看到字符串 'abcd' ,但小程序参数的值只是{{base64}}".
我该如何解决?
解决方案
我解决了传递整个小程序声明的问题.这样它就可以正常工作了.
控制器:
angular.module('jworkApp').controller('AppletCtrl',['$scope', '$sce', function ($scope, $sce) {$scope.b64 = 'AAAA';$scope.applet =""+"<PARAM name=\"testo\" VALUE=\""+$scope.b64+"\"/>"+"</APPLET>";$scope.getAppletCode = function() {返回 $sce.trustAsHtml($scope.applet);};}]);
查看:
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?
解决方案
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>
这篇关于使用 angularJS 绑定小程序参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!