Last active
August 29, 2015 14:07
-
-
Save whisher/e2d6fe7f9140bb3945f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 inmomentNameSpace = angular.module('inmoment', []); | |
| inmomentNameSpace.controller('sampleController', function sampleController($scope,$timeout){ | |
| $scope.cats = []; | |
| db.transaction ( | |
| function(tx) { | |
| $("#catList").empty(); | |
| /* what's the hack is going on here ! | |
| * In the angularjs world is strictly forbidden | |
| * using reference to dom in the controller :) | |
| * Go with a directive instead. | |
| * Possible don't use jquery at all | |
| * but using like angular.element("#catList").empty(); | |
| * https://docs.angularjs.org/api/ng/function/angular.element | |
| * if in the directive you have got the reference to the element | |
| * you can do simple element.empty() | |
| */ | |
| tx.executeSql('SELECT CATEGORY.catID, CATEGORY.Title, CATEGORY.image, COUNT(SUBCATEGORY.subID) as cCount, COUNT(MESSAGETB.mesID) as mCount, SUBCATEGORY.title, SUBCATEGORY.catID FROM CATEGORY LEFT OUTER JOIN SUBCATEGORY ON CATEGORY.catID = SUBCATEGORY.catID LEFT OUTER JOIN MESSAGETB ON SUBCATEGORY.subID = MESSAGETB.subID GROUP BY CATEGORY.catID ORDER BY CATEGORY.Title ASC', [], | |
| function (tx, results) { | |
| var len = results.rows.length; | |
| var catObj = []; | |
| for(var i = 0; i<len; i++) { | |
| catObj[i] = results.rows.item(i); | |
| } | |
| console.log(catObj); | |
| $timeout(function(){ | |
| $scope.cats = catObj; | |
| }); | |
| // using $timeout like above | |
| // is a little hack to trigger | |
| // a $digest cycle | |
| } | |
| ); | |
| } | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment