Created
March 7, 2015 18:04
-
-
Save bkrajendra/50e2b0081a6e9ed22889 to your computer and use it in GitHub Desktop.
onsenui ESP communication example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"light":1,"light_status":"off","somedata":"Hello world!"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var module = angular.module('app', ['onsen']); | |
module.controller("ESPController", function($http, $scope) { | |
$scope.switch1 = function() { | |
alert(lightSwtch.isChecked()) | |
$http.get("a.txt") | |
.success(function(data) { | |
$scope.light = data.light; | |
$scope.light_status = data.light_status; | |
$scope.somedata = data.somedata; | |
}) | |
.error(function(data) { | |
console.log("ERROR: " + data); | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- add this to any of ur <ons-page> tag --> | |
<ons-list modifier="inset" style="margin-top: 10px" ng-controller="ESPController"> | |
<ons-list-item class="to-wrapper"> | |
<ons-row class="" > | |
<ons-col width="60px" class=""> | |
<ons-icon icon="{{light?'fa-bell-o':'fa-bell'}}" size="20px"></ons-icon> | |
</ons-col> | |
<ons-col> | |
<div class="">{{light_status}}</div> | |
<div class="">{{somedata}}</div> | |
</ons-col> | |
</ons-row> | |
</ons-list-item> | |
<ons-list-item> | |
Light | |
<ons-switch modifier="list-item" var="lightSwtch" ng-click="switch1()"></ons-switch> | |
</ons-list-item> | |
<ons-list-item> | |
Plug | |
<ons-switch modifier="list-item" checked></ons-switch> | |
</ons-list-item> | |
</ons-list> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment