Last active
November 16, 2016 21:59
-
-
Save zenithtekla/c3b4db4387b3622902c352b620cf951d to your computer and use it in GitHub Desktop.
equipments.service.js
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
if (!vm.equipment.asset_id) { | |
var equipments = EquipmentsService.query().$promise; | |
equipments.then(function(equipments){ | |
// vm.hints.model = _.map(equipments, 'model'); | |
_.map(equipments, function(equipment){ | |
vm.hints.model.push(equipment.model); | |
vm.hints.asset_number.push(equipment.asset_number); | |
vm.hints.location.push(equipment.ECMS_Location.desc); | |
}); | |
$scope.$watch('vm.equipment.model', function(newVal, oldVal){ | |
if (newVal!==oldVal) vm.hints.asset_number = []; | |
// var b = _.map(_.filter(equipments, {'model' : newVal}), 'asset_number'); | |
vm.hints.asset_number = _(equipments).chain().filter({'model' : newVal}).map('asset_number').value(); | |
/*_.map(equipments, function(equipment){ | |
if (equipment.model === newVal) | |
vm.hints.asset_number.push(equipment.asset_number); | |
});*/ | |
}); | |
}); | |
} |
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
angular | |
.module('calibrates') | |
.factory('EquipmentsService', EquipmentsService); | |
EquipmentsService.$inject = ['$resource']; | |
function EquipmentsService($resource) { | |
var Equipment = $resource('http://localhost:3000/equipments/:asset_id', { | |
asset_id: '@asset_id' | |
}, { | |
update: { | |
method: 'PUT' | |
} | |
}/*,{ | |
stripTrailingSlashes: false | |
}*/); | |
/* var dest = { jj: 'kk'}; | |
var src = { ll: 'oo', nn: 'pp'}; | |
angular.extend(dest, src); | |
console.log('dest ', dest, 'src ', src); // dest: {jj: "kk", ll: "oo", nn: "pp"}, src: { ll: 'oo', nn: 'pp'} | |
*/ | |
angular.extend(Equipment.prototype, { | |
createOrUpdate: function () { | |
var equipment = this; | |
return createOrUpdate(equipment); | |
}, | |
/* createFichier: function () { | |
var documents = this; | |
return createFichier(documents); | |
}*/ | |
}); |
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 EquipmentsListController($state, EquipmentsService, DossiersService) { | |
vm.equipments = EquipmentsService.query(); | |
vm.equipments.$promise.then(function(equipments) { | |
console.log('pick' , _.pick(equipments, ['asset_number'])); | |
}); | |
} |
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
var req = { | |
params: { | |
x: 0, | |
y: 1, | |
z: {}, | |
t: [] | |
}, | |
body: 'sth else', | |
src: 'src-objA', | |
getSrc: function(){ | |
return this.src; | |
} | |
}; | |
var filter = { | |
dossier: 'abc', | |
src: 'dest-objB', | |
location: { | |
id: 1, | |
desc: 'swhere', | |
obj: {}, | |
arr: [] | |
}, | |
getFile: function(){} | |
}; | |
// req.extend(filter) = child.extend(parent) = dest.extend(source) = childClass extends parentClass = dest Class extends source Class | |
// _.extend(req, filter) = _.extend(child, parent) = _.extend(dest, source) = childClass extends parentClass = dest Class extends source Class | |
console.log('merge', _.merge(req, filter)); | |
console.log('assign', _.assign(req, filter)); | |
console.log('extend', _.assignIn(req, filter)); | |
console.log(req.getSrc()); | |
function Foo() { | |
this.a = 1; | |
} | |
function Bar() { | |
this.c = 3; | |
} | |
Foo.prototype.b = 2; | |
Bar.prototype.d = 4; | |
console.log(_.assignIn({ 'a': 0, g: 10}, new Foo, new Bar, { e: 5, f: 6})); // OVERWRITE destination identical properties, EXTEND all prototypes | |
console.log(_.assign({ 'a': 0, g:10 }, new Foo, new Bar, { e: 5, f: 6})); // OVERWRITE destination identical properties, SKIP all prototypes | |
/* function SuperClass (){ | |
//Constructor implementation of this class | |
this.name = 'Piper'; | |
this.age = '43'; | |
//public functions | |
return { | |
parentPublicFunction: function() { | |
//Public function implementation | |
} | |
}; | |
function privateFunction() { | |
//Private function implementation. | |
} | |
} | |
var temp = Object.create(SuperClass.prototype); | |
console.log(temp); | |
console.log({}); */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment