var axiommodule = angular.module("appaxiom", ['ngResource']);
axiommodule.controller("appcontroller", function (axiomservice) {
var vm = this;
vm.hello = "hellow angular";
vm.name = axiomservice.GetStudent();
var student = { Name: 'new', Age: '34', Semester: '4th' };
axiomservice.StudentResource().get({ teacherid: 1 },
function (response)
{
alert(response.Name);
});
//axiomservice.StudentResource.update({id:1},function (response) {
// alert('deleted');
//});
// alert(vm.student);
//.
// then(function (response) {
// alert('');
// });
});
axiommodule.service("axiomservice", function ($http,$resource) {
this.GetStudent = function () {
return "hello ! world angular you are very cruel";
};
this.StudentResource = function () {
return $resource('api/Student', {id:'@id',teacherid:'@teacherid'});
};
});
=========================factory way of calling resource===================
var mod = angular.module('appmodf', ['ngResource']);
mod.controller('gridController', function (gridFactory) {
var vm = this;
gridFactory.studentrepo.query(successCallBack,errorCallBack);
function successCallBack(data)
{
vm.students=data;
}
function errorCallBack(error)
{
vm.error=error;
}
});
mod.factory('gridFactory', function ($resource) {
var service = { studentrepo: $resource(' http://localhost:6074/api/Student/:id/:teacherid', { id: '@id', teacherid: '@teacherid' }) };
return service;
});
axiommodule.controller("appcontroller", function (axiomservice) {
var vm = this;
vm.hello = "hellow angular";
vm.name = axiomservice.GetStudent();
var student = { Name: 'new', Age: '34', Semester: '4th' };
axiomservice.StudentResource().get({ teacherid: 1 },
function (response)
{
alert(response.Name);
});
//axiomservice.StudentResource.update({id:1},function (response) {
// alert('deleted');
//});
// alert(vm.student);
//.
// then(function (response) {
// alert('');
// });
});
axiommodule.service("axiomservice", function ($http,$resource) {
this.GetStudent = function () {
return "hello ! world angular you are very cruel";
};
this.StudentResource = function () {
return $resource('api/Student', {id:'@id',teacherid:'@teacherid'});
};
});
=========================factory way of calling resource===================
var mod = angular.module('appmodf', ['ngResource']);
mod.controller('gridController', function (gridFactory) {
var vm = this;
gridFactory.studentrepo.query(successCallBack,errorCallBack);
function successCallBack(data)
{
vm.students=data;
}
function errorCallBack(error)
{
vm.error=error;
}
});
mod.factory('gridFactory', function ($resource) {
var service = { studentrepo: $resource(' http://localhost:6074/api/Student/:id/:teacherid', { id: '@id', teacherid: '@teacherid' }) };
return service;
});