Góc bao gồm tập lệnh trong chỉ mục html

Bạn sẽ sử dụng các bố cục sau xuyên suốt tài liệu của mình để chỉ định các phần và phần phụ của nội dung

Tiêu đề phần chính

Nội dung phần chính

l-phần-chính h2 Phần Tiêu đề p phần nội dung

Tiêu đề tiểu mục

nội dung phần phụ. Nội dung này có liên quan đến nội dung phần chính và nằm trong phần chính

l-sub-section h3 Sub Section Title p sub section content

Code Examples

Below are some examples of how you can add/customize code examples in a page

Including a code example from the _examples folder

One of the design goals for this documentation was that any code samples that appear within the documentation be 'testable'. In practice this means that a set of standalone testable examples exist somewhere in the same repository as the rest of the documentation. These examples will each typically consist of a collection of html, javascript and css files

Clearly there also needs to be some mechanism for including fragments of these files into the jade/harp generated html. By convention all of the 'testable' examples within this repository should be created within the docs/_examples folder

To include an example from somewhere in the doc/_examples folder you can use the makeExample mixin. This mixin along with the makeTabs mixin both require that the 'included' file be marked up with special comment markers. This markup will be described a bit later

In addition there are several custom gulp tasks that must be run before any of the edits described below will actually appear in the generated documentation. These gulp tasks are documented elsewhere

In order to use the makeExample or makeTabs mixins each page that references the mixins must include the '_utilFns. jade' file on the current page. This is usually accomplished simply by adding a path to this file at the top of any page that needs either of these mixins

include . /_util-fns

The syntax for the makeExample mixin is

+makeExample(filePath, region, title, stylePattern)

  • filePath. path to the example file under the '_examples' folder
  • region. (optional or null) region from the example file to display
  • title. (optional or null) title displayed above the included text
  • stylePattern. (optional or null) allows additional styling via regular expression ( described later)

Example

+makeExample('styleguide/js/src/index. html', null, 'index. html')

This will read the _examples/styleguide/js/src/index. html file and include it with the heading 'index. html'. Note that the file will be properly escaped and color coded according to the extension on the file ( html in this case)

index. html

Documentation Style foo2

The second parameter with a value of 'null' will be described later in this document

There is a similar makeTabs mixin that provides the same service but for multiple examples within a tabbed interface

+makeTabs(filePaths, regions, titles, stylePatterns)

  • filePaths. a comma delimited string of filePaths to example files under the '_examples' folder
  • regions. (optional or null) region from the example file to display
  • titles. (optional or null) a comma delimited string of titles corresponding to each of the filePaths above
  • stylePatterns. (optional or null) allows additional styling via regular expression( described later)

Example

+makeTabs('styleguide/js/src/index. html, styleguide/js/spec. js', null, 'index. html,unit test')

This will create two tabs, each with its own title and appropriately color coded

Documentation Style foo2 describe("Jasmine sample test", function() { it("1+1 should be 2", function() { var result = 1 + 1; expect(result).toBe(2); }); });

Marking up an example file for use by the makeExample and makeTabs mixins

At a minimum, marking up an example file simply consists of adding a single comment line to the top of the file containing the string

.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5. Following this a second string that is the 'name' of the region is also allowed but not required. Một tệp có thể có bất kỳ số lượng
.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 nhận xét nào với yêu cầu duy nhất là tên của từng khu vực trong một tệp phải là duy nhất. Điều này cũng có nghĩa là chỉ có thể có một vùng tài liệu trống

Example of a simple #docregion

// #docregion describe("Jasmine sample test", function() { it("1+1 should be 2", function() { var result = 1 + 1; expect(result). toBe(2);

Nếu một tệp chỉ có một

.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 thì toàn bộ tệp SAU KHI nhận xét
.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 sẽ có sẵn để đưa vào qua mixin. Các phần của tệp có thể được chỉ định bằng cách bao quanh một khu vực của tệp bằng thẻ
.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 và thẻ
table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast
0. These regions, each with its own name, may be nested to any level and any regions that are not 'ended' explicitly are assumed to be ended automatically at the bottom of the file. Regions may either be ended/closed by name or if the name is left blank then the most recent unclosed docregion defined earlier will be closed. Any individual region within the file is accessible to the makeExample and makeTabs mixins

Example of a nested #docregion

(function() { // #docregion // #docregion class-w-annotations var AppComponent = ng // #docregion component . Component({ selector. 'my-app', // #enddocregion component // #docregion view template. 'Ứng dụng góc đầu tiên của tôi' }) // chế độ xem #enddocregion // lớp #docregion. Class({ constructor. function () { } }); // #enddocregion // #enddocregion

Multiple

.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 tags may be defined on a single line as shown below. In addition, anytime a file contains multiple
.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 tags with the same name they will automatically be combined. Each of the individually tagged sections of the combined document will be separated from one another by a comment consisting of '. . . '. This default separator, known as 'plaster' can be overridden anywhere within the affected file via a
table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast
5 comment as shown below. This example creates a separator that consists of
table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast
6 in the output file

// #docplaster more code here // #docregion import,twoparts import { Component } from '@angular/core'; import { bootstrap } from '@angular/platform-browser-dynamic'; // #enddocregion twoparts, import @Component({ selector. 'my-app', template. 'My first Angular App' }) class AppComponent { } // #docregion bootstrap, twoparts bootstrap(AppComponent); // #enddocregion twoparts doSomethingInteresting(); // #enddocregion

HTML files can also contain #docregion comments

<. -- #docregion --> .

as can CSS files

/* #docregion center-global */ . center-global { max-width. 1020px; margin. 0 auto; }

Including a named #docregion via the makeExample or makeTabs mixins

In order to include just a portion of an example file that has been marked up with a 'named'

.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix
5 you will pass the name of the desired region as the 2nd parameter to the makeExample call

Example

+makeExample('styleguide/js/src/app. js', 'class-w-annotations', "Extracted region")

is a request to include just the

table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast
8 region from the
table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast
9 file in the
aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
0 folder and results in the following

Extracted region

app.AppComponent = ng.core.Component({ selector: 'my-app', template: '

My First Angular App

' }) .Class({ constructor: function () { } });

Additional styling

In some cases you may want to add additional styling to an external file after it had been included in the documentation. This styling is accomplished via the

aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
1 and
aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
2 parameters in the makeExample and makeTabs mixins. A
aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
1 is actually just a javascript object where the keys are the names of styles to be applied to some portion of the included text as defined by a regular expression ( or expressions). These regular expressions are the value of each key. Each regular expression MUST specify at least a single capture group; the contents of the capture group being what the style will actually apply to, not the entire regular expression. The idea here is that you may need to include a contextual match in a regular expression but only want your styling to be applied to a subset of the entire regular expression

Current there are only three types of highlight styles available. Outlined (otl), Pink (pnk), and Black (blk), however the mechanism described above will work with any style defined on the page

Example

+makeExample('styleguide/js/src/index. html', null, 'index. html', {pnk. /script (src=. *")/g})

Which will mark all of the quoted contents of each

aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
6 tag within the index. html file in pink

Note that expression replacement occurs AFTER the fragment has been included and html escaped. This means that your regular expression must use escaped html text; i. e. the '"' in the regex above

src/index. html

Documentation Style foo2 src="node_modules/core-js/client/shim.min.js"> foo2

A more complicated example might be

- var stylePattern = { pnk. /script (src=. *")/g, otl. /(\S*my-app. *$)/m }; +makeExample('styleguide/js/src/index. html', null, 'index. html', stylePattern )

Which applies multiple styles and uses an intermediate javascript object as opposed to a literal

index. html

Documentation Style foo2

Hỗ trợ makeTabs cho

aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.
2 hơi khác so với hỗn hợp makeExample ở chỗ bạn cũng có thể chuyển vào một mảng các đối tượng stylePattern trong đó mỗi đối tượng được ghép nối với 'tab' tương ứng của nó. Nếu chỉ một đối tượng stylePattern duy nhất được truyền vào thì nó được coi là áp dụng cho tất cả các tab

-var stylePatterns = [{ pnk. /tập lệnh (src=. *")/g }, {pnk. /(kết quả)/ }]; . html, hướng dẫn kiểu/js/spec. js', null, 'chỉ mục. html,kiểm tra đơn vị', stylePatterns) Kiểu tài liệu foo2 describe("Thử nghiệm mẫu hoa nhài", function() { it("1 . toBe(2); }); });src="node_modules/core-js/client/shim.min.js"> foo2 describe("Jasmine sample test", function() { it("1+1 should be 2", function() { var result = 1 + 1; expect(result).toBe(2); }); });

Including a JSON file or just parts of one

Để bao gồm một '. json' từ một nơi nào đó trong thư mục _examples0, bạn có thể sử dụng mixin _examples1. Không thể sử dụng hỗn hợp makeExamplemakeTabs cho mục đích này vì không có điểm đánh dấu 'nhận xét' tiêu chuẩn trong tệp json

Tuy nhiên, mixin _examples1 cung cấp khả năng tương tự để chọn một cách có chọn lọc các phần của '. json' để hiển thị

Cú pháp cho hỗn hợp _examples1 là

+makeJson(filePath, jsonConfig, tiêu đề, stylePattern)

  • filePath. path to the example file under the '_examples' folder
  • jsonConfig. (tùy chọn) một đối tượng xác định phần nào của. json để chọn hiển thị
    • đường dẫn gốc. (tùy chọn mặc định=null) đường dẫn thuộc tính json mà tại đó tham số 'đường dẫn' bên dưới sẽ bắt đầu
    • con đường. một danh sách các đường dẫn thuộc tính được phân tách bằng dấu phẩy cho các thành phần đó được chọn
    • không gian. (tùy chọn default=" " [2 dấu cách]) một đối tượng Chuỗi hoặc Số được sử dụng để chèn khoảng trắng vào JSON đầu ra
  • tiêu đề. (tùy chọn) tiêu đề hiển thị phía trên văn bản được bao gồm
  • phong cáchHoa văn. (tùy chọn) cho phép tạo kiểu bổ sung thông qua biểu thức chính quy ( được mô tả ở trên)

Example

+makeJson('styleguide/gói. 1. json', null, "Toàn bộ gói. tệp json")

Toàn bộ gói. tập tin json

{ "tên". "angular2-khởi động nhanh", "phiên bản". "1. 0. 0", "tập lệnh". { "tsc". "tsc", "tsc. w". "tsc -w", "lite". "lite-server", "start". "đồng thời \"npm chạy tsc. w\" \"npm run lite\" " }, "giấy phép". "MIT", "phụ thuộc". { "góc2". "2. 0. 0-thử nghiệm. 0", "hệ thống". "0. 19. 6", "core-js". "^2. 4. 0", "rxjs". "5. 0. 0-thử nghiệm. 0", "zone. js". "0. 5. 10" }, "devDependencies". { "kiêm nhiệm". "^1. 0. 0", "máy chủ lite". "^1. 3. 1", "bản đánh máy". "^1. 7. 3" } }

Một tập hợp con của '. json' cũng có thể được chọn

+makeJson('styleguide/package. 1. json', { paths. 'phiên bản, kịch bản. tsc, tập lệnh. start '}, "Các phần được chọn của gói. tệp json")

Các phần được chọn của gói. tập tin json

{ "phiên bản". "1. 0. 0", "tập lệnh". { "tsc". "tsc", "start". "concurrently \"npm run tsc. w\" \"npm run lite\" " } }

Styling selected portions of the json is also supported

+makeJson('styleguide/package. 1. json', {paths. 'dependencies'}, "package. json dependencies", { pnk. [/(\S*zone. *)/, /(\Score-js. *)/, /(\Ssystem. *)/ ]})

package. json dependencies

{ "dependencies". { "angular2". "2. 0. 0-beta. 0", "systemjs". "0. 19. 6", "core-js". "^2. 4. 0", "rxjs". "5. 0. 0-beta. 0", "zone. js". "0. 5. 10" } }

As well as styling across multiple lines

- var styles = { pnk. /(^. *dependencies[\s\S]* \})/gm }; +makeJson('styleguide/package. 1. json', {paths. 'name, version, dependencies '}, "Foo", styles )

Foo

{ "name". "angular2-quickstart", "version". "1. 0. 0", "dependencies". { "angular2". "2. 0. 0-beta. 0", "systemjs". "0. 19. 6", "core-js". "^2. 4. 0", "rxjs". "5. 0. 0-beta. 0", "zone. js". "0. 5. 10" } }

Inline code and code examples provided directly i. e. not from an example file

Cả hai mixin makeExamplemakeTabs đều được xây dựng trên một 'kiểu' ngọc bích tùy chỉnh; . Trong những trường hợp bạn muốn bao gồm mã trực tiếp trong dòng tôi. e. không phải từ một số tệp bên ngoài; . This style has several named attributes

thuộc tính ví dụ mã

  • tên. Name displayed in Tab (required for tabs)
  • ngôn ngữ. javascript, html, etc
  • bỏ trốn. html (escapes html, woot. )
  • định dạng. linenums (or linenums. 4 specify starting line)

Example

code-example(format="linenums" language="javascript"). //SOME CODE

Specify starting line number

code-example(language="html" format="linenums. 4"). var title = "This starts on line four";

Chỉ định một ngôn ngữ

Prettify makes a best effort to guess the language but works best with C-like and HTML-like languages. For others, there are special language handlers that are chosen based on language hints. Thêm một lớp phù hợp với ngôn ngữ mong muốn của bạn (ví dụ bên dưới sử dụng. lang-html)

Title

This is some copy...

Code Highlighting

There are three types of highlights available Outlined, Pink, and Black. You can see examples below and the class names needed for each type

// Pink Background Version // class="pnk" var elephants = "The pink elephants were marching. "; // Black Background Version // class="blk" var night = "The night was pitch black . "; // Outlined Version // class="otl" var match = "The bird ate bird seed near the bird bath ";

Code Tabs

Code Tabs are a great way to show different languages and versions of a particular piece of code. When using these tabs make sure the content is always related

// ES5 var hello = 'blah';// TypeScript var hello = 'blah';

To create code tabs simply use the directives below

code-tabs code-pane(format="linenums" name="Tab 1"). // TAB 1 CONTENT code-pane(format="linenums" name="Tab 2"). // TAB 2 CONTENT

Combining makeExample, makeTabs mixins with code-example style attributes

As mentioned above the makeExample and makeTabs mixins are built on top of the _examples8 style. By default the mixins automatically determine a language based on the example file's extensions and always include line numbers

Bạn có thể ghi đè hành vi này bằng cách bao gồm các thuộc tính ví dụ mã trong dấu ngoặc đơn sau các tham số mixin

Example

+makeExample('styleguide/js/src/app. js', "class-w-annotations")(format="linenums. 15")

Bắt đầu đánh số ví dụ ở dòng 15

app.AppComponent = ng.core.Component({ selector: 'my-app', template: '

My First Angular App

' }) .Class({ constructor: function () { } });

Hoặc để chặn hoàn toàn việc đánh số dòng, bạn có thể sử dụng

+làm Ví dụ('style guide/js/src/app. js', 'class-w-annotations')(format=". ")

app.AppComponent = ng.core.Component({ selector: 'my-app', template: '

My First Angular App

' }) .Class({ constructor: function () { } });

Mã ví dụ trong mã nguồn góc/góc

Các tham chiếu đến mã ví dụ được nhúng trong nguồn góc/góc sử dụng cùng một mixin như được định nghĩa ở trên, nhưng với một cú pháp hơi khác. Thẻ nội tuyến trong nhận xét mã nguồn như {@example. } và {@exampleTabs. } thực sự tạo lệnh gọi mixin 'makeExample' và 'makeTabs' trong tài liệu. Thứ tự của 'đối số' trong các thẻ nội tuyến cũng giống như thứ tự của các mixin được xác định ở trên. Tuy nhiên, các tham số tùy chọn cũng có thể được chỉ định thông qua tên (tùy chọn có tiền tố '-'), như sẽ được minh họa trong ví dụ bên dưới. Các tham số bao gồm khoảng trắng phải được đặt trong dấu ngoặc đơn hoặc dấu ngoặc kép. Cú pháp này nhằm phản ánh các mẫu đối số dòng lệnh tiêu chuẩn

Thẻ nội tuyến '@example' và '@exampleTabs' PHẢI luôn xuất hiện ở đầu dòng. Tất cả các tệp mẫu được tham chiếu bởi các thẻ nội tuyến đều được coi là nằm trong thư mục 'mô-đun/@angular' trong repo góc/góc

@example tham số thẻ nội tuyến

  • filePath. path to the example file under the '_examples' folder
  • region. (optional or null) region from the example file to display
  • title. (optional or null) title displayed above the included text
  • stylePattern. (optional or null) allows additional styling via regular expression ( described later)

ví dụ

/** * Ví dụ không có vùng * {@example core/directives/ng_if_spec. ts -title='Toàn bộ thành phần khác' } * * Một ví dụ có khu vực và tiêu đề được chỉ định theo tên * {@example core/directives/ng_if_spec. ts vùng='ng-if' title='Partial' } * * Một ví dụ khác với vùng và tiêu đề chỉ có tiêu đề được chỉ định rõ ràng. * {@example lõi/chỉ thị/ng_if_spec. ts foo title='Foo' } **/

Thông số thẻ nội tuyến @exampleTabs

  • filePaths. a comma delimited string of filePaths to example files under the '_examples' folder
  • regions. (optional or null) region from the example file to display
  • titles. (optional or null) a comma delimited string of titles corresponding to each of the filePaths above
  • stylePatterns. (optional or null) allows additional styling via regular expression( described later)

ví dụ

/** * Ví dụ về nhiều tab, mỗi tab có khu vực và tiêu đề riêng. * {@exampleTabs lõi/chỉ thị/test1_spec. ts,lõi/chỉ thị/test2_spec. ts vùng='aaa,bbb,' -titles='Kiểm tra 1,Kiểm tra 2' } * **/

Tham chiếu chéo đến các trang hướng dẫn dành cho Nhà phát triển trong các nhận xét nguồn góc cạnh/góc cạnh

'{@linkDevGuide. }' thẻ nội tuyến được dùng để tạo liên kết từ tài liệu api đến tài liệu hướng dẫn nhà phát triển

@linkDevGuide tham số thẻ nội tuyến

  • đường dẫn tập tin. một filePath trỏ đến một trang ngọc bích trong DevGuide mà không có. tiện ích mở rộng ngọc bích (dưới công khai/tài liệu)
  • tiêu đề. Tiêu đề của liên kết. Nếu tiêu đề bị bỏ qua, một nỗ lực sẽ được thực hiện để xác định tiêu đề của trang ngọc bích được trỏ đến. Nếu không tìm thấy thì tiêu đề sẽ chỉ là liên kết

    ví dụ

/** * Liên kết đến ví dụ Hướng dẫn dành cho nhà phát triển có tiêu đề liên kết * Liên kết này có thể xuất hiện ở bất kỳ đâu trong dòng nhận xét. {@linkDevGuide /js/latest/guide/gettingStarted 'Bắt ​​đầu' } * và liên kết tương tự cũng có thể được biểu thị bằng thông số 'tiêu đề' rõ ràng * {@linkDevGuide /js/latest/guide/gettingStarted title='Bắt đầu' . một nỗ lực sẽ được thực hiện để suy ra tiêu đề nếu nó bị bỏ qua. * {@linkDevGuide /js/latest/guide/gettingStarted } **/

cảnh báo

Vui lòng sử dụng cảnh báo một cách tiết kiệm trong toàn bộ tài liệu. Chúng nhằm mục đích thu hút sự chú ý vào những dịp quan trọng. Không nên sử dụng cảnh báo cho nội dung nhiều dòng (thay vào đó là chú thích của người dùng) hoặc xếp chồng lên nhau

Thêm một cảnh báo

Một cảnh báo rất quan trọng

Một cảnh báo rất quan trọng

Một cảnh báo rất hữu ích

.alert.is-critical A very critical alert
.alert.is-important A very important alert
.alert.is-helpful A very helpful alert

Chú thích

Vui lòng sử dụng chú thích một cách tiết kiệm trong toàn bộ tài liệu. Chú thích (như cảnh báo) nhằm thu hút sự chú ý vào những dịp quan trọng. Không giống như cảnh báo, chú thích được thiết kế để hiển thị nội dung nhiều dòng

Thêm chú thích

Một tiêu đề quan trọng

Ký hiệu học hoodie Pitchfork, bữa tiệc mái nhà pop-up túi messenger paleo cred Carles tousled Truffaut năm. Ký hiệu học vi rút miễn phí VHS, Shoreditch phá vỡ McSweeney's. Intelligentsia kale chip Vice bánh mì nướng bốn đô la, cây thánh giá Schlitz

Một tiêu đề rất quan trọng

Ký hiệu học áo hoodie vePitchfork, túi messenger pop-up màu nhạt của bữa tiệc mái nhà tín dụng Carles tóc xù Truffaut năm. Ký hiệu học vi rút miễn phí VHS, Shoreditch phá vỡ McSweeney's. Intelligentsia kale chip Vice bánh mì nướng bốn đô la, cây thánh giá Schlitz

Một tiêu đề rất hữu ích

Ký hiệu học hoodie Pitchfork, bữa tiệc mái nhà pop-up túi messenger paleo cred Carles tousled Truffaut năm. Ký hiệu học vi rút miễn phí VHS, Shoreditch phá vỡ McSweeney's. Intelligentsia kale chip Vice bánh mì nướng bốn đô la, cây thánh giá Schlitz

.callout.is-critical
  header A Critical Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-important
  header A Very Important Title
  p A vePitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

.callout.is-helpful
  header A Very Helpful Title
  p Pitchfork hoodie semiotics, roof party pop-up paleo messenger bag cred Carles tousled Truffaut yr. Semiotics viral freegan VHS, Shoreditch disrupt McSweeney's. Intelligentsia kale chips Vice four dollar toast, Schlitz crucifix

Những cái bàn

Các bảng có thể được sử dụng để trình bày dữ liệu dạng bảng vì nó liên quan đến nhau

Thêm một bảng

FrameworkTaskSpeedAngularJS v. 1. 3RoutingfastAngularJS v. 1. 4Định tuyến nhanh hơnAngularĐịnh tuyến nhanh nhất. )
table
  tr
    th Framework
    th Task
    th Speed
  tr
    td AngularJS v.1.3
    td Routing
    td fast

bên cạnh

Bạn này đối với nội dung có liên quan theo cách tiếp tuyến nhưng không quan trọng đối với việc học thì có thể bỏ qua. Đoạn bao gồm phần tử này phải luôn bao quanh nó bằng văn bản

Thêm một bên

Bạn có biết rằng hipsum là sự thay thế cho Lorem Ipsum? . đồng

Thợ thủ công Etsy Thundercats, bữa tiệc mái nhà sói bền vững đích thực Thiền định áo hoodie XOXO bất đối xứng của thập niên 90. Twee umami bút chì iPhone. Chillwave shabby chic dấu ngã chiếm mực sriracha Nghệ thuật đường phố Brooklyn. Selvage gia truyền kogi American Apparel quyền xe đạp. Quỹ ủy thác Carles Etsy Truffaut mlkshk. Quần short jean thời trang rìu Williamsburg áo len sói râu, twee blog locavore hữu cơ. Dreamcatcher ván trượt Cred, túi đeo hông Bushwick có tính thẩm mỹ thực sự

aside.is-right Did you know that hipsum is a replacement for Lorem Ipsum? To find out more visit hipsum.co

p.
  Etsy artisan Thundercats, authentic sustainable bitters
  wolf roof party meditation 90's asymmetrical XOXO hoodie.
  Twee umami cray iPhone. Chillwave shabby chic tilde
  occupy sriracha squid Brooklyn street art.

Hình ảnh

Để duy trì tính nhất quán về hình ảnh giữa các chương tài liệu, vui lòng làm theo các phương pháp hay nhất dành cho tác giả được nêu trong Hướng dẫn bằng hình ảnh

Chúng tôi có thể thêm thẻ tập lệnh vào HTML trong Angular không?

AngularJS là một khung JavaScript. Có thể thêm nó vào trang HTML bằng thẻ .

LÀM THẾ NÀO để đưa JavaScript vào chỉ mục HTML?

Để bao gồm một tệp JavaScript bên ngoài, chúng ta có thể sử dụng thẻ script với thuộc tính src . Bạn đã sử dụng thuộc tính src khi sử dụng hình ảnh. Giá trị cho thuộc tính src phải là đường dẫn đến tệp JavaScript của bạn. Thẻ tập lệnh này phải được bao gồm giữa các thẻ

Làm cách nào để sử dụng thẻ script trong tệp HTML góc?

Các bước rất đơn giản. .
Tạo một phần tử tập lệnh mới
Sao chép các thuộc tính từ mẫu sang phần tử tập lệnh mới
Sao chép nút văn bản từ mẫu sang phần tử tập lệnh mới
Xóa mẫu
Nối phần tử tập lệnh mới vào DOM của phần tử máy chủ

Nơi bao gồm thẻ tập lệnh trong Angular?

Cách dễ nhất để thêm các phụ thuộc bên ngoài vào các dự án Angular của bạn là thông qua npm. Tùy chọn tốt thứ hai là thêm thẻ tập lệnh vào trang web lưu trữ ứng dụng . Tuy nhiên, tùy chọn đó chỉ hoạt động nếu bạn có quyền truy cập vào trang chủ. Ngoài ra, bạn sẽ phải tải các tệp JavaScript của mình một cách linh hoạt.