Skip to content

Instantly share code, notes, and snippets.

@andrewhl
Created August 31, 2014 01:42
Show Gist options
  • Save andrewhl/cfbe7a91354a7e87f87b to your computer and use it in GitHub Desktop.
Save andrewhl/cfbe7a91354a7e87f87b to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">
<title>Test</title>
</head>
<body ng-app="app" ng-controller="mainController">
<script src="/js/main.js"></script>
</body>
</html>
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module {"_invokeQueue":[["$controllerProvider","register",{"0":"mainController"}]],"_runBlocks":[],"requires":[],"name":...<omitted>...2)
class FoodItemTemplatesController extends \BaseController {
...
public function index()
{
$food_item_templates = $this->foodItemTemplate->all();
return Response::json($food_item_templates);
}
...
}
'use strict';
module.exports = angular.module('foodItemTemplateService', [])
.factory('FoodItemTemplate', function($http) {
return {
get : function() {
return $http.get('/api/food_item_templates');
},
save : function(food_item_templateData) {
return $http({
method: 'POST',
url: '/api/food_item_templates',
headers: { 'Content-Type' : 'application/x-www-form-urlencoded' },
data: $.param(food_item_templateData)
});
},
destroy : function(id) {
return $http.delete('/api/food_item_templates/' + id);
}
}
});
'use strict';
var angular = require('angular');
var mainCtrl = require('./controllers/mainCtrl');
var foodItemTemplateService = require('./services/foodItemTemplateService');
angular.module('app', [mainCtrl, foodItemTemplateService]);
'use strict';
module.exports = angular.module('mainCtrl', [])
.controller('mainController', function($scope, $http, FoodItemTemplate) {
$scope.foodItemTemplateData = {};
$scope.loading = true;
FoodItemTemplate.get()
.success(function(data) {
$scope.foodItemTemplates = data;
$scope.loading = false;
});
$scope.submitFoodItemTemplate = function() {
$scope.loading = true;
FoodItemTemplate.save($scope.foodItemTemplateData)
.success(function(data) {
FoodItemTemplate.get()
.success(function(getData) {
$scope.foodItemTemplates = getData;
$scope.loading = false;
});
})
.error(function(data) {
console.log(data);
});
};
$scope.deleteFoodItemTemplate = function(id) {
$scope.loading = true;
FoodItemTemplate.destroy(id)
.success(function(data) {
FoodItemTemplate.get()
.success(function(getData) {
$scope.foodItemTemplates = getData;
$scope.loading = false;
});
});
};
});
Blade::setContentTags('<%', '%>'); // for variables and all things Blade
Blade::setEscapedContentTags('<%%', '%%>');
...
Route::get('food_item_templates', function() {
return View::make('food_item_templates/index');
});
Route::group(array('prefix' => 'api'), function() {
Route::resource('food_item_templates', 'FoodItemTemplatesController',
array('only' => array('index', 'store', 'destroy')));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment