Struggling with AngularJS and JSON. I have a form.html view where users can select their province. I have a Province JSON file for the select tag, but when storing in MySQL, I need the province Id. I tried using ng-value="province.id" in the option tag but it didn't work. How can I retrieve the pid (provinceId) at the same time the user selects a province?
province.JSON
[
{
"pid" : 1,
"name" : "Ontario"
},
{
"pid" : 2,
"name" : "Québec"
},
{
"pid" : 3,
"name" : "Nova Scotia"
},
{
"pid" : 4,
"name" : "New Brunswick"
},
...
form.html
<select name="province" ng-model="user.province" ng-required="true">
<option value="">--- Please select ---</option>
<option ng-repeat="province in provinces">{{province.name}}</option>
</select>
controllers.js
$scope.submitForm = function (user) {
dataObj = {
"name": user.name, //it works and all fine
"province": user.province, //it works and all fine
"telephone": user.telephone, //it works and all fine
"postalcode": user.postalcode, //it works and all fine
"salary": user.salary, //it works and all fine
"provinceId" : user.pid // undefined ..
}