- Utilizing IonicJS to display JSON data.
- Encountering an error: "Argument 'PeopleController' is not a function, got undefined" I have verified the file people_controller.js
(function() { var app = angular.module('peopleController',[]);
app.controller('PeopleController',
function($scope, $http) {
var url = 'http://localhost:3000/api/people';
$http.get(url)
.success(function(people) {
$scope.people = people;
})
.error(function(data) {
console.log('server side error occurred.');
});
}
);
});
app.js:
angular.module('starter', ['ionic', 'peopleController'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Do not remove this line unless you know what you are doing. It stops the viewport
// from snapping when text inputs are focused. Ionic handles this internally for
// a much nicer keyboard experience.
cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="starter">
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content>
<ul class="list" ng-controller="PeopleController">
<li class="item" ng-repeat="person in people">
<h3>{{person.name}}</h3>
</li>
</ul>
</ion-content>
</ion-pane>
<script src="../js/controllers/people_controller.js"></script>
</body>
</html>
Where am I Going Wrong?