参考链接:
https://github.com/kamranahmedse/developer-roadmap
https://angular.io/tutorial/toh-pt5
@Component is a decorator function that specifies the Angular metadata for the component.
@Component是一个装饰器函数,它为组件指定Angular元数据。
Angular needs to know how the pieces of your application fit together and what other files and libraries the app requires. This information is called metadata
app-routing.module.ts: RouterModule.forRoot(routes)之所以叫forRoot这个方法,是因为你是在app的root层配置的这个router. forRoot方法提供了routing所需的service providers和directives,并且根据目前浏览器的URL跳转到相应的页面;
The <router-outlet> tells the router where to display routed views.
The RouterOutlet is one of the router directives that became available to the AppComponent because AppModule imports AppRoutingModule which exported RouterModule.
RouterOutlet 是一个router directive,能够被AppComponent使用,因为AppModule import了AppRoutingModule ,而AppRoutingModule又export了RouterModule。
routerLink是RouterModule的另外一个router directive
<a> 代表 anchor element
pipe operator ( | )
Pipes are a good way to format strings, currency amounts, dates and other display data. Angular ships with several built-in pipes and you can create your own.
ng generate service
ng generate component
ng generate module app-routing --flat --module=app
ng new test-2019
ng g component my-new-component
ng g directive my-new-directive
ng g pipe my-new-pipe
ng g service my-new-service
ng g class my-new-class
ng g guard my-new-guard
ng g interface my-new-interface
ng g enum my-new-enum
ng g module my-module
javascript-infinite-loop javascript无限循环
js中也有定时器的概念setInterval,如果想实现一个无限循环,可以用定时器:
window.onload = function start() {
slide();
}
function slide() {
var num = 0, style = document.getElementById('container').style;
window.setInterval(function () {
// increase by num 1, reset to 0 at 4
num = (num + 1) % 4;
// -600 * 1 = -600, -600 * 2 = -1200, etc
style.marginLeft = (-600 * num) + "px";
}, 3000); // repeat forever, polling every 3 seconds
}
Angular6在IE上不工作(https://stackoverflow.com/questions/51208921/angular-6-app-not-working-in-ie-11/52771756#52771756):
First open the file in your IDE or text editor: ie-test\src\polyfills.ts Un-comment all the import lines in there. Or just to replace all // import with import
install 2 packages npm install --save classlist.js npm install --save web-animations-js
now ng serve and check
网友评论