angularjs之ng-mode獲取lobject類型裏的鍵值

      有時候數據庫定義的時候,用一個對象來表明某個屬性,以後直接訪問對象就能夠獲取所有該對象的屬性,可是有時需求訪問對象中包含中的鍵值,引用鍵值的時候能夠直接用.來獲取對象的鍵值,好比javascript

對象points: java

 

獲取對象的時候能夠直接數據庫

$scope.points = data.points; //後臺返回數據data

 獲取對象的鍵值spa

$scope.lat = data.points.lat;
$scope.lng = data.points.lng;

 因此咱們要獲取當前值進行修改:3d

頁面code

 <tr ng-repeat="park in parkListView" style="text-align: center;">
                <td>{{park.parkId}}</td>
                <td>{{park.parkName}}</td>
                <td title="parkName">
                    <span ng-if="!park.$edit">{{park.points.lng}}</span>
                    <div ng-if="park.$edit"><input class="form-contrel" type="text" ng-model="park.points.lng" g-model-options="{getterSetter: true}"></div>
                </td>
                <td title="parkName">
                    <span ng-if="!park.$edit">{{park.points.lat}}</span>
                    <div ng-if="park.$edit"><input class="form-contrel" type="text" ng-model="park.points.lat" ng-model-options="{getterSetter: true}" ></div>
                </td>
                <td >{{park.createDate | date:'yyyy/MM/dd HH:mm:ss'}}</td>
                <td title="Actions"><a type="button" class="btn btn-success" ng-if="!park.$edit" ng-click="park.$edit=true">增長</a>
                        
                    <a type="button" ng-if="park.$edit" class="btn btn-info" ng-click="editParkingName(park)">保存</a>
                        
                    <a type="button" ng-if="park.$edit" class="btn btn-default" ng-click="cancelEditName(park.$edit=false)">取消</a></td>
</tr>

  js:orm

        $scope.points = park.points;
        $scope.points.lat = park.points.lat;
        $scope.points.lng = park.points.lng;
        console.info(typeof $scope.points)
        console.info('得到經緯度:'+$scope.points.lat+'====='+$scope.points.lng);
        var opts = {
            editParkId : $scope.editParkId,
            editParkName : $scope.editParkName,
            lat : $scope.points.lat,
            lng : $scope.points.lng
        };
        console.log(opts);

結果截圖:對象

相關文章
相關標籤/搜索