问题描述:

Since breeze can not submit to the database without looking out for mapped entity, then there is a need to extend the model to give you freedom to create your own calculated properties. reference: http://www.johnpapa.net/new-breeze-angular-service/

I have an extended model, using John Papa SPA project pattern,

I have created a table that require submitting a computed properties along with the users input, i.e Date/Time/UsersId i think the only way to achive this is creating an extended model check this link - http://prntscr.com/77cipy

The extended model auditId is a field in the database and bindable object,

Now the problem is, if i want to call the record from the database using ngRepeat and bind the field auditid to view using {{m.auditId}} i keep getting the object from the computed property. Now, i create another property called {{m.formattedAuditId}}

Object.defineProperty(Medication.prototype, 'formattedAuditId', {

get: function () {

var fn = this.auditId;

return fn;

}

});

The Other View Page that get auditId from the database.

 <table class="table table-striped">

<thead>

<th>Generic Name</th>

</thead>

<tr data-ng-repeat="m in vm.medication">

<td>{{m.formattedAuditId}}</td>

<td><strong>{{m.genericName}}</strong></td>

</tr>

</table>

It is still inheriting from the auditId Property i created.

Please what can i do, to bind value from the database instead of the computed property that i created.

Javascript Code:

function registerMedication(metadataStore) {

metadataStore.registerEntityTypeCtor('Medication', Medication);

function Medication() {

//this.isPartial = false;

}

/// This part is the computed property

Object.defineProperty(Medication.prototype, 'auditId', {

get: function () {

var value = moment().format('llll');

return value;

},

set: function (value) {

return value;

}

});

/// This part is where i want the the value to come from the database

Object.defineProperty(Medication.prototype, 'formattedAuditId', {

get: function () {

var fn = this.auditId;

return fn;

}

});

}

The HTML Part

 <form class="contact_form" role="form" id="contact_form">

<fieldset class="left">

<label>Audit Id</label>

<div class="block">

<input data-ng-model="vm.medication.auditId"

placeholder="Patient ID" class="text_input"

type="text" />

</div>

<label>Generic Name</label>

<div class="block">

<input data-ng-model="vm.medication.genericName"

placeholder="Generic Name" class="text_input"

type="text" />

</div>

</fieldset>

</form>

Thanks.

相关阅读:
Top