Last active
August 29, 2015 14:03
-
-
Save bobey/416e2ec23dd8a716399a to your computer and use it in GitHub Desktop.
Angular model with factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @ngInject */ | |
function GouzigouzaController($scope, Gouzigouza) { | |
$scope.gouzigouza = new Gougigouza({ | |
code: 'CODE' | |
}); | |
} | |
angular | |
.module('my.namespace.controllers') | |
.controller('GouzigouzaController', GouzigouzaController); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GouzigouzaFactory() { | |
var Gouzigouza = function Gouzigouza (data) { | |
this.id: data.id; | |
this.code: data.code; | |
}; | |
Gouzigouza.prototype = { | |
/** | |
* @returns {boolean} | |
*/ | |
isNew: function() { | |
return !this.id; | |
} | |
}; | |
return Gouzigouza; | |
} | |
angular | |
.module('my.namespace.resources') | |
.factory('Gouzigouza', GouzigouzaFactory); |
youknowriad
commented
Jul 8, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment