我正在尝试以角度编写此代码:
{prop: string}
我如何在Angular中编写这行代码? 子元素是以角度编写的,但父窗口的代码是简单的javascript代码。 这行代码在子窗口上执行。
答案 0 :(得分:0)
postMessage
API用于传输字符串而不是对象,因此您应该对其进行序列化。
你可以这样做:
opener.window.postMessage(JSON.stringify({code:$scope.variable1,amount:$scope.variable2}), "*");