0

I cant seem to make my angularjs code work with the kik api:

 var myApp = angular.module('myApp', []);
    myApp.controller('MainCtrl', function($scope) {

    $scope.go = function() {  
        kik.send({ 
            title: 'message title',
            text : 'Message body',
            data : {
                       color: 'green',
                       size: 'one'  }       
        });    
    }

    //kik.message is exactly what was provided in kik.send
    //in this case: { color: 'green', size: 'one' } 

    if(kik.message) {     
        $scope.result = kik.message;
    }   
});   

//html ng-app="my-app"
<div controller="MainCtrl">
    <li ng-repeat="todo in result">
        {{todo.color}} {{todo.size}}
    </li>
</div>

$scope.result should hold the data that was inside "api.oppened", but it seems like I made a mistake.

link to API

1 Answers1

0

Looks like your ng-repeat expects result to be an array but it is instead { color: 'green', size: 'one' }. So when you do todo in result, todo isn't the object that you expect it to be.

Simply change your assignment to result:

if (kik.message) {
  $scope.result = [ kik.message ];
}
jairajs89
  • 4,495
  • 3
  • 18
  • 14
  • Are you saying that `kik.message` is undefined? What happens when you simply log `kik.message`? Are you sure that you are opening the Kik message (that's the only way `kik.message` will be defined) – jairajs89 May 26 '14 at 23:42
  • I'm using two phones to test the app. Here is the log from kik.message : `Console.LOG [object Object](http://cdn.kik.com/kik/1.0.9/kik.js:12)` – user3677599 May 27 '14 at 00:18