angularjs材质不导入scss样式

时间:2019-03-21 20:04:47

标签: javascript html css angularjs angularjs-material

我正在使用angularjs 1.7.0中的angularjs材质

我需要具有自动完成功能的多选输入,因此我使用的是材料芯片。 问题是未导入样式。这是我正在使用的代码:

模块:

import angular from 'angular';
import routing from '../../app.config';
import ngMaterial from 'angular-material';

export const HomeModule = angular.module('home-premium', [
    HeroHomePremiumModule,
    ngMaterial 
])
.component('homePremium', HomePremium)
.config(routing);

HTML代码

<md-content class="md-padding" layout="column">
   <md-chips ng-model="$ctrl.selectedDestinies" md-autocomplete-snap
       md-transform-chip="$ctrl.transformChip($chip)"
       md-require-match="true"
       input-aria-label="Destinos">
       <md-autocomplete
          md-selected-item="$ctrl.selectedItem"
          md-search-text="$ctrl.searchText"
          md-items="item in $ctrl.querySearch($ctrl.searchText)"
          md-item-text="item.name"
          input-aria-describedby="autocompleteTitle"
          placeholder="Busca destinos">
            <span md-highlight-text="$ctrl.searchText">{{item.name}}</span>
        </md-autocomplete>
         <md-chip-template>
            <span>
              <strong>{{$chip.name}}</strong>
            </span>
          </md-chip-template>
      </md-chips>
</md-content>

和JS代码:

    import template from './search-by-destiny.html';
const bindings = {
    currentStep: '<',
    changeStep: '&'
};
class SearchByDestinyComponent {
    constructor(utilsService) {
        'ngInject';
        this.utilsService = utilsService;

        this.selectedDestinies = [];
        this.paxNumber = null;
        this.selectedMonths = [];

        this.searchText = null;
        this.destinies = [
            {
                'name': 'Brasil',
                'iata': 'BRS'
            },
            {
                'name': 'Cancún',
                'iata': 'CUN'
            },
            {
                'name': 'Cuba',
                'iata': 'CUB'
            },
            {
                'name': 'México',
                'iata': 'MXC'
            },
            {
                'name': 'España',
                'iata': 'SPN'
            }
        ];
        this.selectedDestinies = [];
        this.readonly = false;
        this.selectedItem = null;
    }

    /**
     * Return the proper object when the append is called.
     */
    transformChip(chip) {
        // If it is an object, it's already a known chip
        if (angular.isObject(chip)) {
            return chip;
        }

        // Otherwise, create a new one
        return { name: chip, iata: 'new' };
    }

    /**
     * Search for destinies.
     */
    querySearch(query) {
        var results = query ? this.destinies.filter(this.createFilterFor(query)) : [];
        return results;
    }

    /**
     * Create filter function for a query string
     */
    createFilterFor(query) {
        var lowercaseQuery = query.toLowerCase();

        return function filterFn(vegetable) {
            return (vegetable.name.toLowerCase().indexOf(lowercaseQuery) === 0) ||
                (vegetable.iata.toLowerCase().indexOf(lowercaseQuery) === 0);
        };

    }

    SearchByDestinyComponent.$inject = ['utilsService'];

    export const SearchByDestiny = {
        template,
        bindings,
        controller: SearchByDestinyComponent
    };

code pen中,看起来像这样good looking md-chips

相反,在我的应用中,它看起来像这样broken md-chips,甚至没有显示下拉列表。

0 个答案:

没有答案