Question

Hey guys I am trying to use rails as a server for my angularjs/kinvey rest application, I am however not very familiar with kinvey or angularjs. I keep receiving the error:

Error: Unknown provider: kinveyProvider <- kinvey

whenever I try to init the kinvey object with relevant credentials.

Here is my relevant setup information:

rails application.js:

//= require jquery
//= require jquery_ujs
//= require angular
//= require kinvey-angular
//= require main
//= require_tree .

main.js:

//define the angular module with dependancy on kinvey
this.crosstrack = angular.module('crosstrack', ['kinvey']);

Kinvey.init({
    appKey    : 'mykey',
    appSecret : 'mysecret'
}).then(function() {
    angular.bootstrap(document, ['crosstrack']);
});

//set the default route
this.crosstrack.config([
    '$routeProvider', function($routeProvider) {
        return $routeProvider.otherwise({
            templateUrl: '../templates/home.html',
            controller: 'HomeCtrl'
        });
    }
]);

My HomeCtrl.js:

crosstrack.controller('HomeCtrl', function ($scope, $kinvey) {

    var promise1 = $kinvey.User.exists('usernametocheck');

    promise1.then(function(){
        $scope.exists='yes';
    }, function(error) {
        $scope.exists=error;
    });

});

Finally my angular template:

<p><label for="name">Check User Existence: </label> <input id="name" type="text"/> {{exists}}</p>

<p>{{kinveyStatus}}</p>

I am sure it is just some conceptual error with how to setup angular/kinvey, I appreciate any tips/help! Thanks!

Was it helpful?

Solution

As the creator of the Kinvey Angular library, I don’t see anything wrong with declaring the Kinvey dependency.

As I cannot comment yet - a few follow up questions: in your HTML-code, do you somewhere use the ngapp="crosstrack" syntax? Also, what version of AngularJS are you using?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top