我应该为 Angular 使用 Material 还是为 AngularJS 使用 Material? [英] Should I use Material for Angular or Material for AngularJS?

查看:23
本文介绍了我应该为 Angular 使用 Material 还是为 AngularJS 使用 Material?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

顺便说一句,这里是个人意见,但很高兴他们决定将布局与组件分开,因此即使您决定使用其他组件,由于 angular/flex-layout,您仍然可以拥有响应式布局.

Angular's GitHub page shows two pinned repositories relating to Material Design:

  1. angular/material2
  2. angular/material

The README.md for angular/material is titled Material Design for AngularJS Apps.

The README.md for angular/material2 is titled Material Design for Angular.

I'm building an Angular2 web application using the angular-cli and have both installed and imported @angular/material into app.module.ts.

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { MaterialModule } from '@angular/material'
import { FlexLayoutModule } from '@angular/flex-layout'

    @NgModule({
      declarations: [
        AppComponent,
      ],
      imports: [
        BrowserModule,
        HttpModule,
        FlexLayoutModule,
        MaterialModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

I assume I should be following the documentation at material.angular.io and not material.angularjs.org?

Questions:

  1. Can someone verify the following is correct?

  2. Given that material.angular.io seems pretty (very?) limited in layouts, components, etc when compared to material.angularjs.org, should I use material.angularjs.org in my application to take advantage of the numerous layouts and widgets, etc?

  3. Can angular/flex-layout be used with both?

解决方案

When building an app with Angular (V2 or +), you should use angular/material2 (github) and the doc at material.angular.io.

Do not use material.angularjs.org as it is for AngularJs apps.

As you noticed, material2 doesn't have much to handle the layout and you should use angular/flex-layout for that.

It's written in material2 repo Readme :

BTW, personal opinion here but it's great that they decided to split the layout from the components so even if you decide to use other components you can still have a responsive layout thanks to angular/flex-layout.

这篇关于我应该为 Angular 使用 Material 还是为 AngularJS 使用 Material?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆