1
votes

After following the OnsenUI Getting Started guide i've begun to develop a Cordova app that works how I like.

I used the Sliding Menu template for the app. So far, so good. I've modified this so that it has the base pages that I want, but now that I'm ready to add functionality, i've searched for adding controllers.

I found the AngularJS Controllers page. To ensure it would work as they suggest, I added it as explained in the document linked. Added the code to app.js, included this in the page (below the Angular and Onsen JS script tags) and added the ng-controller to an ons-page element, but then when I run the app (I'm debugging in Chrome browser with cordova run browser) the controller does not do as intended (the {{ greeting }} tag remains) and the sliding menu functionality is broken - i.e. the hamburger icon disappears, the font isn't loaded and the button is gone. Swipe still works, however.

Inside a div as in the linked example the whole page doesn't break, but the same error occurs and no controller is called.

The chrome error is:

Error: [ng:areq] Argument 'GreetingController' is not a function, got undefined
http://errors.angularjs.org/1.4.8/ng/areq?p0=GreetingController&p1=not%20a%20function%2C%20got%20undefined
    at angular.js:68
    at assertArg (angular.js:1815)
    at assertArgFn (angular.js:1825)
    at angular.js:9158
    at setupControllers (angular.js:8228)
    at nodeLinkFn (angular.js:8270)
    at compositeLinkFn (angular.js:7731)
    at publicLinkFn (angular.js:7611)
    at Class.extend._appendMainPage (onsenui.js:12656)
    at onsenui.js:12735

I've searched to see if there is a parent class I should use but there is hundreds of instances of angular.module() in the code included with the template and I don't know which is the right one to call.

I have downloaded the vanilla template and implemented exactly as outlined on the AngularJS page above and the result is the same so I'm confident it's not my code.

I have removed the ng-controller call in the HTML page and the page works correctly.

I have no idea where to go from here, Chrome profiling doesn't reveal anything to me (but I am certainly not the picture of a Javascript developer).

I'd be appreciative of any help!

1

1 Answers

1
votes

Ended up resolving this. Updated Angular and Onsen using the version supplied in the template - and it worked.

There is a chance I'd accidentally modified one of the supplied file perhaps, or there was a genuine bug in the version I was using. I'll never know.

It's fixed now :)