JElster
asked on
AngularJS - Factory to Set & Get Array / key value
What's the syntax/code to create a factory to hold an array.
Key/Values..
I want to set / get an array of
LASTNAMES
FIRSTNAMES
Be able to add to the array and delete from the array.
Here's I think how you would do a single
thx
angular.module('app').fact ory('testF actory', function() {
var name = '';
var last_name = '';
var color = '';
function setData(n, ln, c) {
name = n;
last_name = ln;
color = c;
}
return {
name: name,
last_name: last_name,
color: color,
setData: setData
}
})
Key/Values..
I want to set / get an array of
LASTNAMES
FIRSTNAMES
Be able to add to the array and delete from the array.
Here's I think how you would do a single
thx
angular.module('app').fact
var name = '';
var last_name = '';
var color = '';
function setData(n, ln, c) {
name = n;
last_name = ln;
color = c;
}
return {
name: name,
last_name: last_name,
color: color,
setData: setData
}
})
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where's the key?
How are you supposed to get the values?
How are you supposed to get the values?
ASKER
So how would I set these values?
Key Value
name Simoes
name Smith
testFactory.setData( name: 'Simoes' );
testFactory.setData( name: 'Smith' );