我得到一个CTRLS是未定义的错误,我不知道在哪里定义ctrls。我是一个完整的noob到angularJS,我想调用烂番茄API来搜索电影。我将在哪里定义CTRLS,以及如何编写代码?“ctrls未定义”错误不知道在哪里定义它
angular.module('demoApp',[])
.constant('apiKey', 'removed for security')
.constant('http://api.rottentomatoes.com/api/public/v1.0')
document.getElementById('searchBox').addEventListener('keydown', function (event) {
if (event.which === 13 || event.keyCode === 13) {
// construct the uri with our apikey
var searchText = this.value;
console.log('Enter works');
ctrls.controller('resultsCTRL', function ($scope, $http) {
$scope.search = searchText;
console.log('control function works');
$http.jsonp('http://api.rottentomatoes.com/api/public/v1.0/movies.json', {
params: {
q: 'toy',
page_limit: 10,
page: 1,
apikey: apiKey,
callback: 'JSON_CALLBACK'
}
});
});
};
});
'ctrls'没有定义。 –