I am building a mobile app using Kendo UI, Angular and IBM Worklight. I am required to use IBM Worklight Adapters to retrieve data from a REST Service. The overall design of the app is following the example at Tutorial: Building applications with Kendo UI Mobile and AngularJS. I can't seem to get the view to get populated with the data from the Worklight Adapter properly. Some code snippets are below. Please advise on the recommended approach to make this work. Thanks.
index.html
controllers.js
accounts.js
index.html
<!DOCTYPE HTML><html> <head> <meta charset="UTF-8"> <title>My Mobile App</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"> <!-- <link rel="shortcut icon" href="images/favicon.png"> <link rel="apple-touch-icon" href="images/apple-touch-icon.png"> --> <!-- CSS --> <link rel="stylesheet" href="css/main.css"> <link href="js/libs/kendoui/styles/kendo.mobile.all.min.css" rel="stylesheet" /> <!-- jQuery --> <!-- Using the jQuery in Kendo UI --> <script src="js/libs/kendoui/js/jquery.min.js"></script> <!-- Angular JS --> <script src="js/libs/angular/1.3/angular.min.js"></script><!-- <script src="js/libs/angular/1.3/angular-route.min.js"></script> --> <!-- Kendo UI --> <script src="js/libs/kendoui/js/kendo.all.min.js"></script> <!-- application scripts --> <script src="js/app.js"></script> <!-- Controllers --> <script src="js/controllers/controllers.js"></script> <script src="js/controllers/accounts.js"></script> <script src="js/controllers/metrics.js"></script> </head> <body style="display:none;" kendo-mobile-application k-hash-bang="true" ng-app="myApp"> <!--application UI goes here--> <!-- Accounts --> <kendo-mobile-view id="accounts" k-title="'Customer Accounts'" k-layout="'default'" ng-controller="AccountsController"> <kendo-mobile-list-view id="accountslist" class="item-list" k-template="templates.accountsTemplate" k-data-source="myAccounts.accountsDataSource"> </kendo-mobile-list-view> </kendo-mobile-view> <!-- Header and Footer --> <kendo-mobile-layout k-id="'default'"> <kendo-mobile-header> <kendo-mobile-nav-bar> <kendo-view-title></kendo-view-title><!-- <kendo-mobile-button class="about-button" k-align="'right'" href="views/about.html">About</kendo-mobile-button> --> </kendo-mobile-nav-bar> </kendo-mobile-header> <kendo-mobile-footer> <kendo-mobile-tab-strip> <a href="#!accounts" data-icon="home">Home</a> <a href="#!" data-icon="organize">View All</a> <a href="#!" data-icon="more">More</a> </kendo-mobile-tab-strip> </kendo-mobile-footer> </kendo-mobile-layout> <!-- Templates --> <script id="accountsTemplate" type="text/x-kendo-template"> <kendo-mobile-button data-item-id="{{dataItem.custno}}"> {{ dataItem.custname }} </kendo-mobile-button> </script> <!-- Standard Worklight Stuff --> <script src="js/initOptions.js"></script> <script src="js/main.js"></script> <script src="js/messages.js"></script> <script type="text/javascript"> WL.Logger.debug("Loading main page"); </script> </body></html>controllers.js
myApp .run(['myAccounts', function(myAccounts){ myAccounts.init(); }]) .service('myAccounts', function() { this.init = function() { // the application DataSource this.accountsDataSource = new kendo.data.DataSource({ data : [{custname: 'JK',custno:'123'},{custname: 'DH',custno:'1234'}] }); // invoke adapter to get data var invocationData = { adapter : 'AccountsAdapter', // adapter name procedure : 'getAccounts', // procedure name parameters : [] // parameters if any }; WL.Client.invokeProcedure(invocationData,{ onSuccess : function(result) { // REST service results data is in result.invocationResult.customers }, onFailure : function(result) { WL.SimpleDialog.show("Error","The service is temporarily not available. Please try again later.",[{text: "OK"}]); } }); // observable array that will be used to store accounts that user has selected this.added = new kendo.data.ObservableArray([]); // field that will hold reference to the last selected account (used for displaying the details) this.currentItem = null; }; this.setCurrentItem = function(id) { this.currentItem = this.accountsDataSource.get(id); }; }) .factory('templates', function() { return { accountsTemplate: $("#accountsTemplate").html() }; });accounts.js
myApp .controller('AccountsController', ['$scope', 'myAccounts', 'templates', function($scope, myAccounts, templates) { $scope.myAccounts = myAccounts; $scope.templates = templates; }]);