我已经通过angular.js开发了一个应用程序-小部件,它将托管在WireCloud中。我需要获得在应用程序中登录的用户的用户名。为此,我必须使用MashupPlatform.context.get(‘用户名’)-但角显然不理解"MashupPlatform“,因为它是一个外部对象。
你知道如何解决这个问题吗?
谢谢
发布于 2015-11-04 12:56:34
最后,这很简单。我有我的路由的html链接,这是假的。我将路由样式更改为javascript ( ng-click ),这样就可以了。
谢谢你们的帮助。
发布于 2015-10-24 10:28:58
就像@Meier说的,当您的小部件加载到Wirecloud中时,会注入MashupPlatform,但是为了在本地测试它,您可以使用 library,它在npm和bower中。目前,几乎所有的线上云0.7都得到了支持,但0.8的支持将于本周到来。
对于本例,您将执行如下操作:
// Create the default values in a dictionary
var preferencesValues = {
'username': 'myusername'
};
// Construct the default values with strategies
var values = {
'prefs.get': MockMP.strategy.dict(preferencesValues)
};
// Construct the MashupPlatform with that values
window.MashupPlatform = new MockMP.MockMP(values);发布于 2015-10-24 08:56:32
当您的小部件部署在Wirecloud平台上时,MashupPlatform将被加载(或注入)。如果您只想在本地测试它,您可以问它是否存在这样的情况:
if (typeof MashupPlatform === 'undefined') {
username = "testusername";
}
else {
username = MashupPlatform.context.get('username');
}https://stackoverflow.com/questions/33305974
复制相似问题