Mohammad Hafiz Mohammad Hafiz - 2 months ago 21
AngularJS Question

search and display same page using angularjs

i need help to solve my problems.
can u help me for display my result after search using angularjs.

html

<form layout="column" ng-submit="submit(propertyquery)">
<span class="md-title" flex style="text-align: center;">
{{ 'title_filter' | translate }}
</span>
<md-input-container flex>
<md-icon class="md-primary">markunread_mailbox</md-icon>
<label>{{ 'title_property_no' | translate }}</label>
<input ng-model="propertyquery.propertyno"
type="text" />
</md-input-container>
<md-input-container flex>
<md-icon class="md-primary">account_balance</md-icon>
<label>{{ 'title_project' | translate }}</label>
<md-select name="projectid"
ng-model="propertyquery.projectid"
ng-value="propertyquery.projectid">
<md-option
ng-repeat="propertyquery in projects"
ng-value="propertyquery.projectid">
{{ propertyquery.code }}
</md-option>
</md-select>
</md-input-container><br>
<md-input-container flex>
<md-icon class="md-primary">domain</md-icon>
<label>{{ 'title_block' | translate }}</label>
<input ng-model="propertyquery.block"
type="text" />
</md-input-container>
<md-input-container flex>
<md-icon class="md-primary">line_weight</md-icon>
<label>{{ 'title_floor' | translate }}</label>
<input ng-model="propertyquery.floor"
type="text" />
</md-input-container>
<md-input-container flex>
<md-icon class="md-primary">store</md-icon>
<label>{{ 'title_lot' | translate }}</label>
<input ng-model="propertyquery.lot"
type="text" />
</md-input-container>
<md-input-container flex>
<md-icon class="md-primary">credit_card</md-icon>
<label>{{ 'title_rental_rm' | translate }}</label>
<input ng-model="propertyquery.rental"
type="text" />
</md-input-container>
<md-input-container flex>
<md-icon class="md-primary">assessment</md-icon>
<div layout="column">
<span class="padding-radio">{{ 'title_status' | translate }}:</span></br>
<div layout="column">
<md-radio-group ng-model="propertyquery.status">
<md-radio-button value="VACANT"
aria-label="radio"
checked>
{{ 'title_vacant' | translate }}
</md-radio-button>
<md-radio-button value="UNDER MAINTENANCE"
aria-label="radio">
{{ 'title_under_maintenance' | translate }}
</md-radio-button>
</md-radio-group>
</div>
</div>
</md-input-container>
<div layout="row" layout-align="end end">
<md-button aria-label="search"
class="md-primary md-raised"
type="submit"
ng-click="filter = '1'">
{{ 'action_submit' | translate }}
</md-button>
</div>




controller

$scope.submit = function(propertyquery)
{
Propertyquery.query({
propertyunitno: propertyquery.propertyunitno,
projectid: propertyquery.projectid,
block: propertyquery.block,
floor: propertyquery.floor,
lot: propertyquery.lot,
rental: propertyquery.rental,
status: propertyquery.status,
}).$promise.then(function()
{

})
};


after i click button submit the result will desplay into html. now i get the result from console. but i can't display the result into table.

do you think i need create new function for call the output?

html

<tbody>
<tr ng-click="read($event, property)"
ng-repeat="property in property">
<td>{{ $index + 1 }}</td>
<td>{{ property.propertyno | uppercase }}</td>
<td>{{ property.block | uppercase }}</td>
<td>{{ property.floor | uppercase }}</td>
<td>{{ property.lot | uppercase }}</td>
<td>RM {{ property.rental | uppercase }}</td>
<td>{{ property.status | uppercase }}</td>
</tr>
</tbody>


how i can display the result after i click button submit.

Nix Nix
Answer

All I did below was set the result of the Propertyquery.query call to $scope.properties

Propertyquery
    .query({ /*.. your code above ..*/})
    .$promise
    .then(_onQuerySuccess)

function _onQuerySuccess(data){
    $scope.properties = data;
}

Then update your template to be:

<tr ng-click="read($event, property)"
    ng-repeat="property in properties">

It was property but I think that is a typo: