无尽长夜吧 关注:239贴子:26,140
  • 5回复贴,共1

Angular: One framework. Mobile & desktop.

取消只看楼主收藏回复

Introduction to the Angular Docs
These Angular docs help you learn and use the Angular platform and framework, from your first app to optimizing complex enterprise apps. Tutorials and guides include downloadable example to accelerate your projects.


IP属地:湖北1楼2019-07-08 16:32回复
    Assumptions
    These docs assume that you are already familiar with HTML, CSS, JavaScript, and some of the tools from the latest standards, such as classes and modules. The code samples are written using TypeScript. Most Angular code can be written with just the latest JavaScript, using types for dependency injection, and using decorators for metadata.


    IP属地:湖北2楼2019-07-08 16:33
    回复
      Feedback
      You can sit with us!
      We want to hear from you. Report problems or submit suggestions for future docs.
      Contribute to Angular docs by creating pull requests on the Angular Github repository. See Contributing to Angular for information about submission guidelines.
      Our community values respectful, supportive communication. Please consult and adhere to the Code of Conduct.


      IP属地:湖北3楼2019-07-08 16:33
      回复
        Getting Started with Angular: Your First App
        Welcome to Angular!
        This tutorial introduces you to the essentials of Angular. It leverages what you already know about HTML and JavaScript—plus some useful Angular features—to build a simple online store application, with a catalog, shopping cart, and check-out form. You don't need to install anything: you'll build the app using the StackBlitz online development environment.
        We are using the StackBlitz Generator to show you a ready-made, simple application that you can examine and play with interactively. In actual development you will typically use the Angular CLI, a powerful command-line tool that lets you generate and modify applications. For more information, see the CLI Overview.
        NEW TO WEB DEVELOPMENT?
        You'll find many resources to complement the Angular docs. Mozilla's MDN docs include both HTML and JavaScript introductions. TypeScript's docs include a 5-minute tutorial. Various online course platforms, such as Udemy and Codecademy, also cover web development basics.


        IP属地:湖北4楼2019-07-08 16:35
        回复
          Output
          The "Notify Me" button doesn't do anything yet. In this section, you'll set up the product alert component so that it emits an event up to the product list component when the user clicks "Notify Me". You'll define the notification behavior in the product list component.
          Open product-alerts.component.ts.
          Import Output and EventEmitter from @angular/core:
          src/app/product-alerts/product-alerts.component.tscontent_copyimport { Component } from '@angular/core';import { Input } from '@angular/core';import { Output, EventEmitter } from '@angular/core';
          In the component class, define a property named notify with an @Output decorator and an instance of event emitter. This makes it possible for the product alert component to emit an event when the value of the notify property changes.
          content_copyexport class ProductAlertsComponent { @Input() product; @Output() notify = new EventEmitter();}
          In the product alert template (product-alerts.component.html), update the "Notify Me" button with an event binding to call the notify.emit() method.
          src/app/product-alerts/product-alerts.component.htmlcontent_copy<p *ngIf="product.price > 700"> <button (click)="notify.emit()">Notify Me</button></p>
          Next, define the behavior that should happen when the button is clicked. Recall that it's the parent (product list component)—not the product alerts component—that's going to take the action. In the product-list.component.ts file, define an onNotify() method, similar to the share() method:
          src/app/product-list/product-list.component.tscontent_copyexport class ProductListComponent { products = products; share() { window.alert('The product has been shared!'); } onNotify() { window.alert('You will be notified when the product goes on sale'); }}
          Finally, update the product list component to receive output from the product alerts component.
          In product-list.component.html, bind the app-product-alerts component (which is what displays the "Notify Me" button) to the onNotify() method of the product list component.
          src/app/product-list/product-list.component.htmlcontent_copy<button (click)="share()"> Share</button><app-product-alerts [product]="product" (notify)="onNotify()"></app-product-alerts>
          Try out the "Notify Me" button:
          Learn more: See Component Interaction for more information about listening for events from child components, reading child properties or invoking child methods, and using a service for bi-directional communication within the family.


          IP属地:湖北9楼2019-07-08 16:42
          回复
            Next stepslink
            Congratulations! You've completed your first Angular app!
            You have a basic online store catalog, with a product list, "Share" button, and "Notify Me" button. You've learned about the foundation of Angular: components and template syntax. You've also learned how the component class and template interact, and how components communicate with each other.
            To continue exploring Angular, choose either of the following options:
            Continue to the "Routing" section to create a product details page that can be accessed by clicking a product name and that has its own URL pattern.
            Skip ahead to the "Deployment" section to move to local development, or deploy your app to Firebase or your own server.


            IP属地:湖北10楼2019-07-08 16:42
            回复