The first Polymer Application, polymer

Source: Internet
Author: User

The first Polymer Application, polymer
Original article: Step 3: Using data binding
Translated on: February 1, July 7, 2014
Translated by: Tie

The personal information card we created is pretty good, but for the whole application, only one card looks a little empty. In this section, data binding of Polymer is used to display a series of cards.


To obtain data, you must use<Post-service>Element. This element provides a very simple API for virtual social networks. In this section, you will usePostsAttribute, which returnsPostArray composed of objects:

{  "uid": 2,  "text" : "Loving this Polymer thing.",  "username" : "Rob",  "avatar" : "../images/avatar-02.svg",  "favorite": false}

Edit post-list.html files

Go to the starter directory under the root directory and open it in the editor. Post-list.htmlFile.
<Link rel = "import" href = ".. /components/polymer/polymer.html "> <link rel =" import "href =" post-service.html "> <link rel =" import "href =" post-card.html "> <polymer-element name = "post-list" attributes = "show"> <template> <style>: host {display: block; width: 100%;} post-card {margin-bottom: 30px ;}</style> <! -- Other labels can be added here -->...
Description:
  • The file already contains<Post-service>Element import, so you can use it directly.
  • AttributeAttributes = "show"A published property named show is created ).
One Published property(Publish attribute) means that one attribute can be configured in a tag, or two-way data binding can be used to connect to another attribute. You will use ShowAttribute.

Bytes ------------------------------------------------------------------------------------

In the element's <Template>Add <Post-service>Element:
  ...  <post-service id="service" posts="{{posts}}">  </post-service>  ...  
Description:
  • Posts = "{posts }}"Attribute in<Post-service>Two-way data binding is added to your custom elements.
Data binding PostsProperty to a local property, also known Posts). All methods you define in custom elements can be passed through This. postsAccess this response object.

Bytes ----------------------------------------------------------------------------------------------------------------
Display Dynamic list card

In <Post-service>Add the following <Div>And <Template>Tags:
<div layout vertical center>  <template repeat="{{post in posts}}">    <post-card>            

Description:
  • This new syntaxRepeat = "{post in posts }}"To make the templatePostsCreate a new instance for each item in the array.
  • In each template instance{Post. avatar }}) Will be replaced by the corresponding values in the item.
Edit the index.html File
Set <Post-list>Element Import Index.html

Open Index.htmlAnd introduce Post-list.htmlFile to add the import link. You can use Post-list.htmlReplace existing Post-card.htmlFile:
<link rel="import" href="post-list.html">
Bytes -------------------------------------------------------------------------------------

Use the <post-list> element.

Find <Post-card>Element, and then replace it <Post-list>:
...<div class="container" layout vertical center>  <post-list show="all"></post-list></div>...

Test Results

Save (it is recommended to save it at any time during editing. This is a good coding habit) Index.htmlFile, deploy, and then use chrome to open the link or refresh the page, for example:
Http: // localhost: 8080/polymer-tutorial-master/starter/index.html

The result is as follows:
Figure step 3 shows the effect after completion.
If an error occurs or is not displayed, you can Step 3Directory Post-list.html, index.htmlFile comparison, of course, you can also directly access this file to try the effect.

Practice:
Open Post-service.htmlCheck the working mechanism of the component. Internally, it uses <Core-ajax>Element to execute the HTTP request.

Next section

Step 4: Close the work


Before creating the first IWin32Window object in the application, you must call SetCompatibleTextRenderingDefault. How to modify the application name Project --> Setting --> Link: output file name --> Debug/AppName.exe ---------------------------------------------------- VC6.018 Practical Tips 1. check whether the program brackets match. To move the cursor, check the brackets (braces {}, square brackets [], Parentheses (), and angle brackets <>) press the shortcut key Ctrl +] to match the brackets correctly. The cursor jumps and matches the brackets. Otherwise, the cursor moves and the chassis horn generates a warning. 2. view macros (or variables, functions) macro definition move the cursor To know if the macro is more common than DECLARE_MAP_MESSAGE and press F12 (or right-click the menu Go To Defition ...), If Browse files is not created, a prompt is displayed, indicating that some items will be jumped and defined in the dialog box. You can also see that Microsoft defined system macros are very good. 3. formatting segments messy source code segment selection source code by ATL + F8 4. the member variables or functions found in the editing status can display and delete the project extension. re-open the project in the ncb file. how to organize the ClassView view a large number of class classview views right-click to create a folder (new folder) and drag the corresponding folder of similar classes to make the entire view clear. 6. position pre-processing: Specify the source file to locate the cursor symmetric # if, # endif, use Ctrl + K. 7. add system Lib current Project | Settings | Link | Object/library modules: enter a blank space between Lib names and Lib. 8. add the system header file (. h) current project. # include: Tell the compiling VC system directory to find it; Use # include "FileName. h "shows the current directory for compilation. 9. he Studio uses Assembly debugging WorkBenchDebugger to press CTRL + F7. 10. for example, ClassZiard needs ClassWizard to find system messages and process system messages such as WM_NCHITTEST, please change the Message filter on the ClassWizardClass Info page to Window. 11. how to clean the deletion class first Delete the corresponding from WorkspaceFileView. h and. cpp file, and then close the project to delete the corresponding from the actual folder. h and. cpp file and. clw file 12. quick Switch between two files in Studio sometimes we need to quickly switch between the two files in the near future. 13. obtain the source program preprocessing: Choose Studio> PROJECT> SETTINGS> C/C ++> Project Options and add the/P/EP compilation switch to perform "only preprocessing ". the file name is found in the directory of the compiled source program. I text file pre-processing knot (Note: Please set the size to large/P) 14. view the WINAPI call return value in Debug mode: simple and practical: Add @ hr to watch. For more information about errCSDN, see section 15. generate the assembly code of the specified source program file: Open the Project Settings from the IDE menu Project> Setting and press the file to do: 1. select two more files on the left. select List Files on the right C ++ property page category, and then select Assembly and source code for List Files Type (or select) list File Name input C/C ++ source File to generate the corresponding assembly code File 3. compile the entire project 16. manually compile pure resources into dll: Rc.exe/v data. rc Cvtres.exe/machine: ix86 data. res Link/SUBSYSTEM:
Compared with plastic, Polymer and ABS are collectively referred to as plastic, while ABS plastic is classified as polymerABS with single-monomer copolymer.

I know which kind of music instrument I have come into contact with the drums. Its drum film is made of plastic. It is called PET. When it is low-end, there are also PVC countries. Traditionally, it is also useful for cowhide. It requires that PET be able to fight against scratches and other problems. sound is also sweet; as for its musical instrument, there are few plastic or rubber parts are polymer. As for the ABS characteristics of the material, the surface gloss is good, the hardness is also wrong. The appearance is beautiful. For the tone, it depends on various situations. LZ is interested in reading some polymers. the book will introduce more about polymer. I know more about the application of musical instruments. I should have read the books on the manufacture of musical instruments.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.