Mein API-Aufruf gibt HTML zurück, aber wenn dieser HTML-Code leer ist, z. Ich bekomme eine Konsolen-HTML-Antwort von "", ich möchte eine Standardnachricht mit Knockout anzeigen. Ich vermute also, dass es erkennen muss, dass "" leer ist und dann meinen alternativen Inhalt anzeigt.
anzeigen Modell -Wenn die HTML-Antwort Null ist, wird alternativer Inhalt angezeigt
var MyText = ko.observable();
var company = shell.authenticatedCompany();
hazibo.helpTextGet(company.name, company.userName, company.password).then(function (data) {
MyText(data);
});
return {
MyText: MyText
};
View -
<section class="help-text">
<div class="flex-container">
<div class="flex-item" data-bind="html: MyText">This is my alternate message if the html response is ""</div>
</div>
</section>