使用angularjs更改文本颜色

时间:2017-05-24 14:37:00

标签: javascript java html css angularjs

我有这个部分代码:

<div style="margin-top:25px;"
     ng-class="{'color-red': $ctrl.clientStatus === 'Error', 'color-blue': $ctrl.clientStatus === 'Warning', 'color-green': $ctrl.clientStatus === 'OK'}">
    Status: {{$ctrl.filesToUploadClientStatus}}</div>

和此组件代码:

(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';
...
}

为什么我在添加这个时会得到一个破解的HTML?

ng-class="{'color-red': $ctrl.clientStatus === 'Error', 'color-blue': $ctrl.clientStatus === 'Warning', 'color-green': $ctrl.clientStatus === 'OK'}">
        Status: {{$ctrl.filesToUploadClientStatus}}

0 个答案:

没有答案