Trying to figure out a good way to convert an unknown quantity of attributes passed into an angular directive into an array for odata purposes.
<my-directive pagenum="3" itemcount="40" name="Thompson" something="blah" ></my-directive>
..My directive .js file contains so far
link: function(scope, elem, attrs) {
//pseudo code//
var attrArray = {};
foreach (attrs.$attr as someattrname){
attrArray[someattrname] = attrs.someattrname; // Of course this doesnt work.
}
scope.runListQuery(attrArray); // they get serialized into an odata url in here
},
controller:['$scope','myDataFactory', function($scope,myDataFactory) {
$scope.runListQuery = function(attrs) {
myDataFactory.getQuery(attrs).success(function(data){
$scope.items = data;
});
};
attrArrayas an array instead of an object. Tryvar attrArray = [];