When loading my webpage, I get the following errors:
Error: [ng:areq] Argument 'LFSTD' is not a function, got undefined
Uncaught ReferenceError: controller is not defined
The webpage i'm loading has the ng-app attribute in the body tag, and a Ionic tag has the ng-controller:
<body ng-app="ia">
[...]
<ion-side-menu-content ng-controller="LFSTD">
"ia" and "LFSTD" are both defined in app.js. The webpage does load the following static files correctly
This is app.js:
angular.module('ia', ['ionic'])
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
controller('LFSTD', function($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
};
});
});
})
I've been struggling with this, lurking stackoverflow and ionic/angular docs for quite a while. It might be worth saying that my project uses Django. Any idea what might be causing these errors?
Solution
angular
.module('ia', ['ionic'])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'create.html',
controller: 'LFSTD'
})
}
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
controller('LFSTD', function($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
};
});
});
})
I was missing the .controller part in app.js. I thought I could include controllers in a function, but no. It needs to be directly after the angular.module. See updated question.