Angular ntsiab lus projection yog dab tsi?
Angular ntsiab lus projection yog dab tsi?

Video: Angular ntsiab lus projection yog dab tsi?

Video: Angular ntsiab lus projection yog dab tsi?
Video: Kev yos hav zoov ceev faj muaj ntau yam 09/07/2020 2024, Kaum ib hlis
Anonim

Cov ntsiab lus projection tso cai rau koj ntxig tus duab ntxoov ntxoo DOM hauv koj cov khoom. Txhawm rau muab nws yooj yim, yog tias koj xav ntxig cov ntsiab lus HTML lossis lwm yam khoom hauv ib qho khoom, ces koj ua qhov ntawd siv lub tswv yim ntawm cov ntsiab lus projection . Hauv Angular , koj ua tiav cov ntsiab lus projection siv <ng- cov ntsiab lus >< /ng- cov ntsiab lus >.

Tsuas yog li ntawd, cov ntsiab lus projection yog dab tsi?

Cov ntsiab lus projection (tseem hu ua transclusion) yog ib txoj hauv kev los import HTML cov ntsiab lus . los ntawm sab nraum lub tivthaiv thiab ntxig rau ntawd cov ntsiab lus nyob rau hauv cov khoom template. nyob rau hauv ib qho chaw. Yog li ntawd, siv cov ntsiab lus - qhov projection koj tuaj yeem tau txais qhov tshwm sim hauv qhov. raws li duab.

Tsis tas li ntawd, angular Transclusion yog dab tsi? Hloov pauv yog ib qho tseem ceeb heev thiab muaj txiaj ntsig zoo ntawm AngularJS cov lus qhia. Nws tso cai rau cov lus qhia siv tus qauv thaum tseem muaj peev xwm los clone cov ntsiab lus qub thiab ntxiv rau DOM. Hloov pauv tso cai rau cov lus qhia los ua kom muaj zog, cov ntaub ntawv-tsav DOM cov qauv uas tsim kom muaj kev txaus siab rau cov neeg siv.

Kuj tseem paub, Ng cov ntsiab lus hauv angular yog dab tsi?

Koj siv lub < ng - cov ntsiab lus ></ ng - cov ntsiab lus > tag raws li qhov chaw rau qhov dynamic cov ntsiab lus , ces thaum lub template yog parsed Angular yuav hloov qhov chaw cim npe nrog koj cov ntsiab lus.

Dab tsi yog Shadow DOM hauv angular?

Duab ntxoov ntxoo DOM yog zoo li ib tug parallel DOM tsob ntoo tuav hauv ib qho kev tivthaiv (ib lub ntsiab lus HTML, tsis txhob totaub nrog Angular Cheebtsam), zais deb ntawm lub ntsiab DOM tsob ntoo. Nws yog qhov kev siv ntawm cov Duab ntxoov ntxoo DOM txheem uas tso cai rau saib, style, thiab coj cwj pwm encapsulation.

Pom zoo: