Ändern Sie die Textfarbe mit AngularJs
Posted: 09 Apr 2025, 20:55
Ich habe diesen Teilcode: < /p>
Code: Select all
ng-class="{'color-red': $ctrl.clientStatus === 'Error', 'color-blue': $ctrl.clientStatus === 'Warning', 'color-green': $ctrl.clientStatus === 'OK'}">
Status: {{$ctrl.filesToUploadClientStatus}}
< /code>
Und dieser Komponentencode: < /p>
(function (app) {
app.component('uploadFilesComponent', {
templateUrl: 'partials/upload-files-partial.html',
// bindings: {filesToUpload: '=', hasFilesOnServer : '='},
controller: ['$scope', '$state','uploadService', function ($scope, $state, uploadService) {
...
var self = this;
var NO_FILES_TO_UPLOAD = "No files to upload";
var WAITING_FOR_UPLOAD = "Waiting for upload";
self.clientStatus = self.filesToUploadClientStatus.contains(WAITING_FOR_UPLOAD) ? 'OK' : 'Error';
...
}
< /code>
Warum erhalte ich beim Hinzufügen eines HTML? < /p>
ng-class="{'color-red': $ctrl.clientStatus === 'Error', 'color-blue': $ctrl.clientStatus === 'Warning', 'color-green': $ctrl.clientStatus === 'OK'}">
Status: {{$ctrl.filesToUploadClientStatus}}