Javascript 无法在Rails上的angular脚本中使用$http.get和未定义的$scope读取JSON文件
问题1:我有以下代码:Javascript 无法在Rails上的angular脚本中使用$http.get和未定义的$scope读取JSON文件,javascript,ruby-on-rails,json,angularjs,Javascript,Ruby On Rails,Json,Angularjs,问题1:我有以下代码: <script> function ProductionIndexCtrl($scope, $http) { $http.get('POD.json').success(function(data) { $scope.results = data.results; console.log("Here"); }).e
<script>
function ProductionIndexCtrl($scope, $http) {
$http.get('POD.json').success(function(data) {
$scope.results = data.results;
console.log("Here");
}).error(function(data, status, headers, config) {
console.log('error');
});
};
</script>
但似乎每次运行它时,都会出现$scope未定义的错误。
我已经在我的视图html文件的顶部包含了ng应用程序,并在我想要包含的$scope周围包含了我的ng控制器指令。但我似乎仍然错过了一些东西。有什么想法吗
@temp.controller 'ProductionCtrl', [
'$scope',
'$http',
(($scope, $http) ->
$scope.results =
[
{
"name": "1",
"location": "a",
"status": "g",
"size": "3551"
}
]