This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16113|Reply: 1

[Angular] angularjs sets up the mqtt client to get the data

[Copy link]
Posted on 8/14/2017 1:06:09 PM | | |
https://github.com/shellus/angular-MQTT
Get a third-party angular library and import it into your project.
<scrip{filter}t src="bower_components/angular/angular.js"></scrip{filter}t><scrip{filter}t src="bower_components/angular-mqtt/src/browserMqtt.js"></scrip{filter}t><scrip{filter}t src="bower_components/angular-mqtt/src/angular-MQTT.js"></scrip{filter}t>
    varapp=angular.module('app', [        'ngMQTT'    ]);    app.config(['MQTTProvider',function(MQTTProvider) {        MQTTProvider.setHref('ws://cv.endaosi.com:18585');    }]);    app.controller('indexCtrl', ['$scope', 'MQTTService', function($scope, MQTTService) {        MQTTService.on('hello', function(data) {            alert(data)        });        MQTTService.send('hello','word');        MQTTService.send('hello','word1');        MQTTService.send('hello','word2');    }]);

Score

Number of participants1MB+3 contribute+3 Collapse reason
Little scum + 3 + 3 Banana Rewards Program

See all ratings





Previous:Discuz 3.3 and later QQ interconnection and cloud platform issues
Next:SVG vector drawing path path explanation (basic drawing method)
Posted on 8/14/2017 1:29:41 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com