I'm trying to push attributes to a json file and I'm getting an error...
TypeError: Cannot read property 'push' of undefined
This is my controller....
'use strict';
(function () {
var userQuoteBuild = angular.module('priceQuoteApp');
userQuoteBuild.controller('quoteBuilderController', function ($scope, $http, $timeout, productsServices, userQuoteBuild) {
$scope.getProductDetails = function (item) {
userQuoteBuild.setProductName(item.product_name)
userQuoteBuild.SelectedProductattributes1.push({
bearerBandwidth: '100',
description: 'item2'
});
};
});
userQuoteBuild.controller('productDisplayer', function ($scope, userQuoteBuild) {
$scope.userQuoteBuild = userQuoteBuild;
$scope.$watch(function () { return userQuoteBuild.getProductName(); }, function (newValue) {
if (newValue) $scope.selected_product_name = newValue;
});
});
}());
and this is where I am keeping the json....
var userQuoteBuild = angular.module('priceQuoteApp');
userQuoteBuild.factory('userQuoteBuild', function () {
var SelectedProductattributes1 = [{
bearerBandwidth: '',
description: ''
}];
});
Can anyone see what I am doing wrong? Thanks