我在一个node.js服务器上测试了IBMIoTF,它运行良好。 IBMIoTF你可以在这里找到:https://www.npmjs.com/package/ibmiotf如何在WebApplication中使用IBMIoTF for node.js?
现在我想用IBMIoTF在web应用和我注意到在文件中这个小注:https://www.npmjs.com/package/ibmiotf#load-the-library-in-browser
加载在浏览器 负载IOTF客户端库-bundle.js或dist目录中的iotf-client-bundle-min.js
我也看了看http://browserify.org/,但我无法让它工作。
它能够加载库在的index.html
<script src="libs/iotf/iotf-client-bundle.min.js"></script>
,但我怎么能角模块中创建一个对象实例?
选项1
我不能够使用需要web应用。
var config = {
"org": "THEORG",
"id": "IOT_WEB_APPLICATION",
"auth-key": "THEKEY",
"auth-token": "THETOKEN",
"type" : "shared"
};
var IotClient = require('ibmiotf');
var iotClient = new IotClient.IotfApplication(config);
在这种情况下,我得到
angular.js:14110 ReferenceError: require is not defined
选项2
我还试图用一个对象,我在IOTF-client.js文件中找到。
module.exports = {
IotfDevice: _IotfDevice['default'],
IotfManagedDevice: _IotfManagedDevice['default'],
IotfGateway: _IotfGateway['default'],
IotfManagedGateway: _IotfManagedGateway['default'],
IotfApplication: _IotfApplication['default']
};
并没有在我的控制器这样的实现:
var config = {
"org": "THEORG",
"id": "IOT_WEB_APPLICATION",
"auth-key": "THEKEY",
"auth-token": "THETOKEN",
"type" : "shared"
};
var iotClient = new IotfApplication(config);
在这里,我得到:
angular.js:14110 ReferenceError: IotfApplication is not defined
这些选项没有工作,但如何创建一个的实例IBMIoTF? 任何人都可以帮助我吗?
刘若英您好,感谢您的反馈意见。我做了一个基本的样本这里https://github.com/thomassuedbroecker/browserfied-ibmiotf-webapplication的斜网应用程序。关心托马斯 –