app.controller('MyController', function($scope, MyService) {
// ...
});MyController.$inject = ["$scope", "$http", "MyService"];
function MyController($scope, $http, MyService) {
// code
}app.controller('MyController',
['$scope', 'MyService',
function ($scope, MyService) {
// code
}
]);Text
// Simple GET request example:
$http.get('/someUrl').
success(function(data, status, headers, config) {
// this callback will be called asynchronously
// when the response is available
}).
error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});Text
// Simple POST request example (passing data) :
$http.post('/someUrl', {msg:'hello word!'}).
success(function(data, status, headers, config) {
}).
error(function(data, status, headers, config) {
});Transform your code from this:
fs.readFile("file.json", function(err, val) {
if( err ) {
console.error("unable to read file");
}
else {
try {
val = JSON.parse(val);
console.log(val.success);
}
catch( e ) {
console.error("invalid json in file");
}
}
});fs.readFileAsync("file.json")
.then(JSON.parse)
.then(function(val) {
console.log(val.success);
})
.catch(SyntaxError, function(e) {
console.error("invalid json in file");
})
.catch(function(e){
console.error("unable to read file")
});Into this: