Can anyone explain why the variable panodataName
is becoming empty when used inside the function $scope.addPanodata
?
HTML:
<input type="text" class="form-control" ng-model="panodataName" style="width:auto;padding:0;">
<a class="btn btn-primary" href="javascript:;" ng-click="addPanodata(pano.objectId)">Add</a>
JS:
angular.module('yoApp')
.controller('addPanoCtrl', function($q, $scope, $rootScope, $routeParams, serviceUpload) {
$scope.panodataName = ''
$scope.addPanodata = function(panoId) {
var Panodata = AV.Object.extend('PanoramaData'),
panodata = new Panodata(),
panoJSON = _.where($scope.building.pano, {'objectId': panoId})
$scope.pano = panoJSON[0]
console.log($scope.panodataName)
console.log($scope.panodataName)
panodata.save(json, {
success: function(object) {
},
error: function(object, error) {
}
})
}
I've noticed that if I use {{panodataName}} within curly braces, it shows the correct value of the input.
panodataName
displays the correct value of the input.
EDIT:
Could it be related to the fact that it's being used inside an ng-repeat
block?
<div class="col-md-6" ng-repeat="panodata in pano.panoData">