how to set value of ng-model with dot from controller?
<input type=text" ng-model="user.latitude">
this doesn't work:
$scope.user.latitude = myLat;
You need to create user object first:
$scope.user = {};
$scope.user.latitude = myLat;
or shorter:
$scope.user = {latitude: myLat};
This is the only possible way of doing this. You have to make an object first then only you can enter something into it.
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
First Name: <input type="text" ng-model="name.fname"><br>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name={};
$scope.name.fname="test";
//$scope.name={fname:"test"};
});
</script>
</body>
</html>