how to know the bootstrap version in angular-cli

open the following file

"../node_modules/bootstrap/dist/css/bootstrap.css",

can find the following from the header of the file

/*!
* Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com)
* Copyright 2011-2017 The Bootstrap Authors
* Copyright 2011-2017 Twitter, Inc.
*/
/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */

 

Advertisements
Posted in angular4, Bootstrap, Uncategorized | Leave a comment

install bootstrap with angular-cli

https://github.com/angular/angular-cli/wiki/stories-include-bootstrap

Include Bootstrap

Bootstrap is a popular CSS framework which can be used within an Angular project. This guide will walk you through adding bootstrap to your Angular CLI project and configuring it to use bootstrap.

Using CSS

Getting Started

Create a new project and navigate into the project

ng new my-app
cd my-app

Installing Bootstrap

With the new project created and ready you will next need to install bootstrap to your project as a dependency. Using the --save option the dependency will be saved in package.json

# version 3.x
npm install bootstrap --save

# version 4.x
npm install bootstrap@next --save

Configuring Project

Now that the project is set up it must be configured to include the bootstrap CSS.

  • Open the file .angular-cli.json from the root of your project.
  • Under the property apps the first item in that array is the default application.
  • There is a property styles which allows external global styles to be applied to your application.
  • Specify the path to bootstrap.min.css

    It should look like the following when you are done:

    "styles": [
      "../node_modules/bootstrap/dist/css/bootstrap.min.css",
      "styles.css"
    ],

Note: When you make changes to .angular-cli.json you will need to re-start ng serve to pick up configuration changes.

Testing Project

Open app.component.html and add the following markup:

<button class="btn btn-primary">Test Button</button>

With the application configured, run ng serve to run your application in develop mode. In your browser navigate to the application localhost:4200. Verify the bootstrap styled button appears.

Using SASS

Getting Started

Create a new project and navigate into the project

ng new my-app --style=scss
cd my-app

Installing Bootstrap

# version 3.x
npm install bootstrap-sass --save

# version 4.x
npm install bootstrap@next --save

Configuring Project

Create an empty file _variables.scss in src/.

If you are using bootstrap-sass, add the following to _variables.scss:

$icon-font-path: '../node_modules/bootstrap-sass/assets/fonts/bootstrap/';

In styles.scss add the following:

// version 3
@import 'variables';
@import '../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap';

// version 4
@import 'variables';
@import '../node_modules/bootstrap/scss/bootstrap';

Testing Project

Open app.component.html and add the following markup:

<button class="btn btn-primary">Test Button</button>

With the application configured, run ng serve to run your application in develop mode. In your browser navigate to the application localhost:4200. Verify the bootstrap styled button appears. To ensure your variables are used open _variables.scss and add the following:

$brand-primary: red;

Return the browser to see the font color changed.

Posted in angular4, Bootstrap, Uncategorized | Leave a comment

add child to a route

  • use {path:’xx’, component:xxx, children:[{…}]}
  • the {path:’xx’, loadChildren:’…’} will not make it children, instead it will be the peer
  • prefix based matching – it will match the url segment 1 by 1
Posted in angular4 | Leave a comment

apply custom pipe to whole app

  • create the pipe
  • create a module and import/export the pipe
    • import { KeysPipe } from ‘../keys.pipe’;
      @NgModule({
      imports: [
      CommonModule
      ],
      declarations: [KeysPipe],
      exports: [KeysPipe]
      })
  • for each app module, import the pipe module
    • import { CpipeModule } from ‘app/util/cpipe/cpipe.module’;
      import { SystemAdminComponent } from ‘./system-admin.component’;
      @NgModule({
      imports: [
      CommonModule,
      CpipeModule,
      SystemAdminRoutingModule
      ],
      declarations: [SystemAdminComponent]
      })
Posted in angular4 | Leave a comment

support IE

go to polyfills.ts and uncomments those lines for IE

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import ‘core-js/es6/symbol’;
// import ‘core-js/es6/object’;
// import ‘core-js/es6/function’;
// import ‘core-js/es6/parse-int’;
// import ‘core-js/es6/parse-float’;
// import ‘core-js/es6/number’;
// import ‘core-js/es6/math’;
// import ‘core-js/es6/string’;
// import ‘core-js/es6/date’;
// import ‘core-js/es6/array’;
// import ‘core-js/es6/regexp’;
// import ‘core-js/es6/map’;
// import ‘core-js/es6/set’;
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import ‘classlist.js’; // Run `npm install –save classlist.js`.
/** IE10 and IE11 requires the following to support `@angular/animation`. */
// import ‘web-animations-js’; // Run npm install --save web-animations-js
Posted in angular4, Uncategorized | Leave a comment

config & service for each module or for app?

  • config
    • does each module need it’s own config?
      • the routing is for its own
Posted in Design, Uncategorized | Leave a comment

dynamically load all component or not?

  • benefit
    • fully configurable
    • easy for change
  • problem
    • where to put the component logic?
    • not able to use the good editor
      • not efficient for programming

=> how many changes can happen? is it frequent?

not many changes

  • the build will go through the import chain, non-relevant component will not be built => no impact to the build? what if the import is there, but logic actually not needed?
  • better way => dev each component in the editor,  use configuration to tell which one to use?

 

Posted in Design, Uncategorized | Leave a comment