What is Coffee Token (CFT) | What is Coffee Wallet | What is CFT token

In this article, we’ll discuss information about the Coffee Wallet project and CFT token

Coffee Token (CFT) is a utility token for Coffee Wallet project. Tokens were created to croudfund the project. You can buy CFT to support and invest in further development of this open source project.

Coffee Wallet is an open source, multi cryptocurrency wallet with integrated portfolio and many other features like paper wallets generator, “send via message” or integrated exchange.

Besides supporting the project, CFT will give the following benefits: All CFT holders will become premium users (ads removed, discounts on provisions when buying or exchanging crypto). Other crypto projects will be able to pay with CFT for an ad inside of the app or use Coffee Wallet to airdrop their tokens to users. CFT will also be used to provide a symbolic reward for new users for completing a gamified tutorial. This will ensure they understand basic wallet concepts while giving them real value.

Coffee Wallet

Coffee Wallet is an open source, multi cryptocurrency wallet with integrated portfolio and many other features like paper wallets generator, “send via message” or integrated exchange.

Wallet

Send and receive coins using your device. Use generated keys or import wallets. Support for BTC, ETH, DOGE, LTC, ERC20 tokens and  more.

Portfolio

Whether you use hardware, paper or a third-party wallet, you can add addresses or balances to your ‘offline’ portfolio to keep track.

Exchange

Simply swap one cryptocurrency to another using centralised and decentralised exchanges directly from your wallet.

Open

Code is available under terms of Open Source license. And this is  more important that one might think.

Secure

Signed transactions are sent to third party providers. Private keys never leave your device. This makes you the owner of your own money.

Light

Created with Cordova and Vanilla JS, Coffee Wallet is light and able to run on multiple platforms and devices, even in your browser.

All features

  • Full wallet support for: BTC, ETH, LTC, ERC20 tokens, and more
  • Portfolio support for other coins.
  • Add address to your portfolio to keep track of its balance.
  • Configurable display currency and price source ( CoinGecko,  CoinMarketCap,  Coinpaprika)
  • Receive payment with QR code. Send payments using QR codes scanner.
  • Send payment requests with configurend ammounts.
  • Face/fingerprint authentication. If your device supports it, you will be asked to authenticate before sending payments.
  • BIP39 mnemonic support. Easy to backup 12-word passphrase generates all your private keys.
  • Exchange support. Use  Uniswap,  Changelly or  ChangeNow to exchange your coins without leaving the app!
  • Send crypto as a message (share via SMS, Messanger etc.)
  • Printable PDF paper wallet generator.
  • Bitcoin Testnet and Ethereum Ropsten support (usable tool for devs)
  • BIP72 payments (for example  bitpay)

Why Open Source?

“we keep part of our development in secret, in order to protect our users”

frequently repeated lie

You own your money only if you own your keys but how do you know if you really own your keys if you dont know what your software is doing? Wise man once said that a chain is only as strong as its weakest link. Same goes for secutity, decentralisation and privacy of systems.

Do you invest in a revolutionary technology that allows sending peer-to-peer transactions in a decentralised, transparent and secure manner but you make transaction using a closed software or you keep your assets on a centralised service? You might be doing something wrong. The sole purpose of blockchain is to allow transactions without trusted third party involvement.

That’s why transparency is a must in the decentralised world. The whole  source code of Coffee Wallet is available and you can even build it yourself.

Dowload Coffee Wallet: https://play.google.com/store/apps/details?id=coffee.software.coffeewallet

Coffee Token

Coffee Token (CFT) is a utility token for Coffee Wallet project. Tokens were created to croudfund the project. You can buy CFT to support and invest in further development of this open source project.

Tokens Utility

Besides supporting the project, CFT will give the following benefits: All CFT holders will become premium users (ads removed, discounts on provisions when buying or exchanging crypto). Other crypto projects will be able to pay with CFT for an ad inside of the app or use Coffee Wallet to airdrop their tokens to users. CFT will also be used to provide a symbolic reward for new users for completing a gamified tutorial. This will ensure they understand basic wallet concepts while giving them real value.

Technical Details

CFT is deployed on Ethereum blockchain as an ERC20 token at 0x5bf2390a68ab7db7d27ae81894c4e22e669af236 with 18 decimals

Coffee Token (CFT) is an ERC20 token with a closed supply of 7 000 000 (seven million) units.

1 000 000 Initial airdrop : 100 tokens per installation to improve App popularity, visibility and credibility in stores

1 000 000 Private ICO :

• Finish developing of 1.0 version (see above)
• Security Audit, to increase credibility
• Launching and Advertising public ICO, deploying website and ICO contract
• Legal counseling

4 000 000 Public ICO : Developing 2.0 version (see above)

1 000 000 Reserved: Project founder and team

How and Where to Buy Coffee Token (CFT) ?

Coffee Token has been listed on a number of crypto exchanges, unlike other main cryptocurrencies, it cannot be directly purchased with fiats money. However, You can still easily buy this coin by first buying Bitcoin, ETH, USDT, BNB from any large exchanges and then transfer to the exchange that offers to trade this coin, in this guide article we will walk you through in detail the steps to buy CFT

You will have to first buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

We will use Binance Exchange here as it is one of the largest crypto exchanges that accept fiat deposits.

Once you finished the KYC process. You will be asked to add a payment method. Here you can either choose to provide a credit/debit card or use a bank transfer, and buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

SIGN UP ON BINANCE

Step by Step Guide : What is Binance | How to Create an account on Binance (Updated 2021)

Next step - Transfer your cryptos to an Altcoin Exchange

Since CFT is an altcoin we need to transfer our coins to an exchange that CFT can be traded. Below is a list of exchanges that offers to trade CFT in various market pairs, head to their websites and register for an account.

Once finished you will then need to make a BTC/ETH/USDT/BNB deposit to the exchange from Binance depending on the available market pairs. After the deposit is confirmed you may then purchase CFT from the exchange: Coinsbit

Contract: 0x5bf2390a68ab7db7d27ae81894c4e22e669af236

Apart from the exchange(s) above, there are a few popular crypto exchanges where they have decent daily trading volumes and a huge user base. This will ensure you will be able to sell your coins at any time and the fees will usually be lower. It is suggested that you also register on these exchanges since once CFT gets listed there it will attract a large amount of trading volumes from the users there, that means you will be having some great trading opportunities!

Top exchanges for token-coin trading. Follow instructions and make unlimited money

https://www.binance.com
https://www.bittrex.com
https://www.poloniex.com
https://www.bitfinex.com
https://www.huobi.com
https://www.mxc.ai
https://www.probit.com
https://www.gate.io
https://www.coinbase.com

Find more information CFT

WebsiteWebsite 2ExplorerWhitepaperSource CodeSocial Channel Social Channel 2Social Channel 3Message BoardCoinmarketcap

🔺DISCLAIMER: The Information in the post is my OPINION and not financial advice, is intended FOR GENERAL INFORMATION PURPOSES ONLY. Trading Cryptocurrency is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money.

🔥 If you’re a beginner. I believe the article below will be useful to you

⭐ ⭐ ⭐ What You Should Know Before Investing in Cryptocurrency - For Beginner ⭐ ⭐ ⭐

Thank for visiting and reading this article! Please don’t forget to leave a like, comment and share!

#bitcoin #cryptocurrency #cft #coffee token

What is GEEK

Buddha Community

What is Coffee Token (CFT) | What is Coffee Wallet | What is CFT token

What is Coffee Token (CFT) | What is Coffee Wallet | What is CFT token

In this article, we’ll discuss information about the Coffee Wallet project and CFT token

Coffee Token (CFT) is a utility token for Coffee Wallet project. Tokens were created to croudfund the project. You can buy CFT to support and invest in further development of this open source project.

Coffee Wallet is an open source, multi cryptocurrency wallet with integrated portfolio and many other features like paper wallets generator, “send via message” or integrated exchange.

Besides supporting the project, CFT will give the following benefits: All CFT holders will become premium users (ads removed, discounts on provisions when buying or exchanging crypto). Other crypto projects will be able to pay with CFT for an ad inside of the app or use Coffee Wallet to airdrop their tokens to users. CFT will also be used to provide a symbolic reward for new users for completing a gamified tutorial. This will ensure they understand basic wallet concepts while giving them real value.

Coffee Wallet

Coffee Wallet is an open source, multi cryptocurrency wallet with integrated portfolio and many other features like paper wallets generator, “send via message” or integrated exchange.

Wallet

Send and receive coins using your device. Use generated keys or import wallets. Support for BTC, ETH, DOGE, LTC, ERC20 tokens and  more.

Portfolio

Whether you use hardware, paper or a third-party wallet, you can add addresses or balances to your ‘offline’ portfolio to keep track.

Exchange

Simply swap one cryptocurrency to another using centralised and decentralised exchanges directly from your wallet.

Open

Code is available under terms of Open Source license. And this is  more important that one might think.

Secure

Signed transactions are sent to third party providers. Private keys never leave your device. This makes you the owner of your own money.

Light

Created with Cordova and Vanilla JS, Coffee Wallet is light and able to run on multiple platforms and devices, even in your browser.

All features

  • Full wallet support for: BTC, ETH, LTC, ERC20 tokens, and more
  • Portfolio support for other coins.
  • Add address to your portfolio to keep track of its balance.
  • Configurable display currency and price source ( CoinGecko,  CoinMarketCap,  Coinpaprika)
  • Receive payment with QR code. Send payments using QR codes scanner.
  • Send payment requests with configurend ammounts.
  • Face/fingerprint authentication. If your device supports it, you will be asked to authenticate before sending payments.
  • BIP39 mnemonic support. Easy to backup 12-word passphrase generates all your private keys.
  • Exchange support. Use  Uniswap,  Changelly or  ChangeNow to exchange your coins without leaving the app!
  • Send crypto as a message (share via SMS, Messanger etc.)
  • Printable PDF paper wallet generator.
  • Bitcoin Testnet and Ethereum Ropsten support (usable tool for devs)
  • BIP72 payments (for example  bitpay)

Why Open Source?

“we keep part of our development in secret, in order to protect our users”

frequently repeated lie

You own your money only if you own your keys but how do you know if you really own your keys if you dont know what your software is doing? Wise man once said that a chain is only as strong as its weakest link. Same goes for secutity, decentralisation and privacy of systems.

Do you invest in a revolutionary technology that allows sending peer-to-peer transactions in a decentralised, transparent and secure manner but you make transaction using a closed software or you keep your assets on a centralised service? You might be doing something wrong. The sole purpose of blockchain is to allow transactions without trusted third party involvement.

That’s why transparency is a must in the decentralised world. The whole  source code of Coffee Wallet is available and you can even build it yourself.

Dowload Coffee Wallet: https://play.google.com/store/apps/details?id=coffee.software.coffeewallet

Coffee Token

Coffee Token (CFT) is a utility token for Coffee Wallet project. Tokens were created to croudfund the project. You can buy CFT to support and invest in further development of this open source project.

Tokens Utility

Besides supporting the project, CFT will give the following benefits: All CFT holders will become premium users (ads removed, discounts on provisions when buying or exchanging crypto). Other crypto projects will be able to pay with CFT for an ad inside of the app or use Coffee Wallet to airdrop their tokens to users. CFT will also be used to provide a symbolic reward for new users for completing a gamified tutorial. This will ensure they understand basic wallet concepts while giving them real value.

Technical Details

CFT is deployed on Ethereum blockchain as an ERC20 token at 0x5bf2390a68ab7db7d27ae81894c4e22e669af236 with 18 decimals

Coffee Token (CFT) is an ERC20 token with a closed supply of 7 000 000 (seven million) units.

1 000 000 Initial airdrop : 100 tokens per installation to improve App popularity, visibility and credibility in stores

1 000 000 Private ICO :

• Finish developing of 1.0 version (see above)
• Security Audit, to increase credibility
• Launching and Advertising public ICO, deploying website and ICO contract
• Legal counseling

4 000 000 Public ICO : Developing 2.0 version (see above)

1 000 000 Reserved: Project founder and team

How and Where to Buy Coffee Token (CFT) ?

Coffee Token has been listed on a number of crypto exchanges, unlike other main cryptocurrencies, it cannot be directly purchased with fiats money. However, You can still easily buy this coin by first buying Bitcoin, ETH, USDT, BNB from any large exchanges and then transfer to the exchange that offers to trade this coin, in this guide article we will walk you through in detail the steps to buy CFT

You will have to first buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

We will use Binance Exchange here as it is one of the largest crypto exchanges that accept fiat deposits.

Once you finished the KYC process. You will be asked to add a payment method. Here you can either choose to provide a credit/debit card or use a bank transfer, and buy one of the major cryptocurrencies, usually either Bitcoin (BTC), Ethereum (ETH), Tether (USDT), Binance (BNB)…

SIGN UP ON BINANCE

Step by Step Guide : What is Binance | How to Create an account on Binance (Updated 2021)

Next step - Transfer your cryptos to an Altcoin Exchange

Since CFT is an altcoin we need to transfer our coins to an exchange that CFT can be traded. Below is a list of exchanges that offers to trade CFT in various market pairs, head to their websites and register for an account.

Once finished you will then need to make a BTC/ETH/USDT/BNB deposit to the exchange from Binance depending on the available market pairs. After the deposit is confirmed you may then purchase CFT from the exchange: Coinsbit

Contract: 0x5bf2390a68ab7db7d27ae81894c4e22e669af236

Apart from the exchange(s) above, there are a few popular crypto exchanges where they have decent daily trading volumes and a huge user base. This will ensure you will be able to sell your coins at any time and the fees will usually be lower. It is suggested that you also register on these exchanges since once CFT gets listed there it will attract a large amount of trading volumes from the users there, that means you will be having some great trading opportunities!

Top exchanges for token-coin trading. Follow instructions and make unlimited money

https://www.binance.com
https://www.bittrex.com
https://www.poloniex.com
https://www.bitfinex.com
https://www.huobi.com
https://www.mxc.ai
https://www.probit.com
https://www.gate.io
https://www.coinbase.com

Find more information CFT

WebsiteWebsite 2ExplorerWhitepaperSource CodeSocial Channel Social Channel 2Social Channel 3Message BoardCoinmarketcap

🔺DISCLAIMER: The Information in the post is my OPINION and not financial advice, is intended FOR GENERAL INFORMATION PURPOSES ONLY. Trading Cryptocurrency is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money.

🔥 If you’re a beginner. I believe the article below will be useful to you

⭐ ⭐ ⭐ What You Should Know Before Investing in Cryptocurrency - For Beginner ⭐ ⭐ ⭐

Thank for visiting and reading this article! Please don’t forget to leave a like, comment and share!

#bitcoin #cryptocurrency #cft #coffee token

Diego  Elizondo

Diego Elizondo

1657359660

Usar Variables De Referencia De Plantilla En Angular

En esta publicación, aprenderá cómo usar variables de referencia de plantilla, a menudo conocidas como "Referencias de plantilla", en Angular.

En Angular, los componentes tienen una templatepropiedad que contiene elementos y otros componentes. Una variable de referencia de plantilla es una característica que nos permite acceder a una parte de nuestra plantilla.

Esto podría ser un elemento, componente o podría ser una directiva. Las variables de referencia de plantilla están inteligentemente implementadas y se pueden usar de varias maneras.

La primera podría ser simplemente exportar una referencia a un elemento. Aquí podemos adjuntar un #a un <input>y proporcionar un nombre de variable (de ahí la referencia de plantilla 'variable'):

<input type="text" #coffee>

Puede pensar en esta sintaxis como una "exportación". Estamos exportando una referencia al elemento.

Eso significa que ahora podemos acceder a las propiedades de esa variable de referencia como si nos la devolvieran a través de JavaScript simple (piense en lo que obtendría document.querySelector('input')y eso es lo que tenemos aquí):

<input type="text" #coffee>

<p>{{ coffee.value }}</p>

Esto cerraría la sesión como una cadena vacía coffee.value, ya que no tenemos value. Nuestra coffeevariable nos está dando directamente un HTMLInputElement.

Para que podamos ver el valor a medida que escribimos, necesitaríamos introducir la ngModelDirectiva:

<input type="text" ngModel #coffee>

<p>{{ coffee.value }}</p>

Pruébelo y escriba algo en el <input>:

https://stackblitz.com/edit/angular-ivy-t3y6jt?file=src%2Fapp%2Fapp.component.ts

Así que aquí está la próxima gran característica de las referencias de plantilla.

Exportemos una referencia a nuestro ngModely cambiemos el contexto de lo que #coffeenos devuelve.

Al especificar #coffee, dejamos implícitamente que Angular decida qué exportar, porque no estamos especificando nada más que enlazar con el elemento.

Estamos vinculantes ngModel, que ahora es 'parte de' nuestro <input>. Vamos a exportarlo:

<input type="text" ngModel #coffee="ngModel">

<p>Value: {{ coffee.value }}</p>
<p>Pristine: {{ coffee.pristine }}</p>
<p>Touched: {{ coffee.touched }}</p>

Al pasar #coffee="ngModel", vinculamos explícitamente una referencia a nuestra ngModeldirectiva rastreada.

Ya no tenemos un HTMLInputElement. Tenemos una referencia a NgControl.

Puede consultar el código fuente de NgControl aquí, que amplía las clases NgControl y AbstractControlDirective .

¿Por qué estamos viendo esto? Porque le muestra todas las propiedades disponibles para usted, que es exactamente la razón por la que hemos mencionado no solo valuepero pristiney touchedtambién.

Pruébelos a continuación, nuestra variable de referencia de plantilla está reflejando ngModel:

Podemos promover esto y acceder a una referencia de plantilla dentro de un componente , de modo que podamos acceder a propiedades y métodos desde dentro classy no solo desde template.

https://stackblitz.com/edit/angular-ivy-jwci6u?file=src%2Fapp%2Fapp.component.ts

Esto se logra mediante el uso de quizás TemplateRefo ElementRefjunto con un @ViewChilddecorador. Lea el artículo anterior sobre cómo hacerlo y un trabajo más profundo, pero esencialmente se ve así:

@Component({...})
export class AppComponent {
  @ViewChild('username') input: ElementRef<HTMLInputElement>;
}

Esa es una buena introducción a las referencias de plantilla, y espero que le brinde una comprensión más profunda de cómo usarlas, cuándo y dónde. No solo esto, sino qué esperar cuando declara una referencia de plantilla y cómo exportar también referencias a cosas como directivas.

¡Feliz refrigerio! 

Fuente: https://ultimatecourses.com/blog/angular-template-reference-variables

#angular 

Hoang  Kim

Hoang Kim

1657363440

Cách Sử Dụng Biến Tham Chiếu Mẫu Trong Angular

Trong bài đăng này, bạn sẽ tìm hiểu cách sử dụng Biến tham chiếu mẫu, thường được gọi là “Tóm tắt mẫu”, trong Angular.

Trong Angular, các thành phần có một templatethuộc tính, chứa các phần tử và các thành phần khác. Biến tham chiếu mẫu là một tính năng cho phép chúng tôi có quyền truy cập vào một phần của mẫu của chúng tôi.

Đây có thể là một phần tử, thành phần hoặc có thể là một chỉ thị. Các biến tham chiếu mẫu được triển khai khéo léo và có thể được sử dụng theo nhiều cách khác nhau.

Đầu tiên có thể chỉ là xuất một tham chiếu đến một phần tử. Tại đây, chúng ta có thể đính kèm a #vào một <input>và cung cấp một tên biến (do đó, tham chiếu mẫu 'biến'):

<input type="text" #coffee>

Bạn có thể coi cú pháp này như một "xuất khẩu". Chúng tôi đang xuất một tham chiếu đến phần tử.

Điều đó có nghĩa là bây giờ chúng tôi có thể truy cập các thuộc tính trên biến tham chiếu đó như thể nó được trả lại cho chúng tôi thông qua JavaScript thuần túy (hãy nghĩ xem bạn sẽ lấy lại được gì khi sử dụng document.querySelector('input')và đó là những gì chúng tôi có ở đây):

<input type="text" #coffee>

<p>{{ coffee.value }}</p>

Điều này sẽ đăng xuất một chuỗi trống coffee.valuevì chúng tôi không có value. coffeeBiến của chúng tôi đang trực tiếp cung cấp cho chúng tôi một HTMLInputElement.

Để chúng tôi thấy giá trị khi chúng tôi nhập, chúng tôi cần giới thiệu ngModelChỉ thị:

<input type="text" ngModel #coffee>

<p>{{ coffee.value }}</p>

Hãy thử và nhập một cái gì đó vào <input>:

https://stackblitz.com/edit/angular-ivy-t3y6jt?file=src%2Fapp%2Fapp.component.ts

Vì vậy, đây là tính năng tuyệt vời tiếp theo của refs mẫu.

Hãy xuất một tham chiếu đến của chúng tôi ngModelvà thay đổi ngữ cảnh của những gì #coffeetrả về cho chúng tôi.

Bằng cách chỉ định #coffee, chúng tôi đang ngầm cho phép Angular quyết định những gì sẽ xuất, bởi vì chúng tôi không chỉ định bất kỳ điều gì khác ngoài ràng buộc với phần tử.

Chúng tôi đang ràng buộc ngModel, hiện là 'một phần' của chúng tôi <input>. Hãy xuất nó:

<input type="text" ngModel #coffee="ngModel">

<p>Value: {{ coffee.value }}</p>
<p>Pristine: {{ coffee.pristine }}</p>
<p>Touched: {{ coffee.touched }}</p>

Bằng cách chuyển #coffee="ngModel", chúng tôi đang ràng buộc một cách rõ ràng một tham chiếu đến ngModelchỉ thị được theo dõi của chúng tôi.

Không còn chúng tôi có một HTMLInputElement. Chúng tôi có một tài liệu tham khảo NgControl.

Bạn có thể kiểm tra mã nguồn cho NgControl tại đây, mã này mở rộng các lớp NgControlAbstractControlDirective .

Tại sao chúng ta nhìn vào điều này? Bởi vì nó hiển thị cho bạn mọi thuộc tính có sẵn cho bạn, đó chính là lý do tại sao chúng tôi đã tham khảo không chỉ valuemà còn pristinecả touched.

Hãy thử chúng bên dưới, biến tham chiếu mẫu của chúng tôi đang phản ánh ngModel:

Chúng ta có thể tiếp tục điều này và truy cập vào một tham chiếu mẫu bên trong một thành phần , vì vậy chúng ta có thể truy cập các thuộc tính và phương thức từ bên trong classchứ không chỉ template.

https://stackblitz.com/edit/angular-ivy-jwci6u?file=src%2Fapp%2Fapp.component.ts

Điều này đạt được thông qua việc sử dụng có lẽ TemplateRefhoặc ElementRefcùng với một @ViewChildngười trang trí. Đọc bài viết trên về cách thực hiện và làm việc sâu hơn, nhưng về cơ bản nó trông như thế này:

@Component({...})
export class AppComponent {
  @ViewChild('username') input: ElementRef<HTMLInputElement>;
}

Đó là một phần giới thiệu hay về các ref mẫu và tôi hy vọng nó sẽ cung cấp cho bạn một số hiểu biết sâu hơn về cách sử dụng chúng, khi nào và ở đâu. Không chỉ điều này, mà còn những gì sẽ xảy ra khi bạn khai báo một ref mẫu và cách cũng xuất các tham chiếu đến những thứ như chỉ thị.

Nguồn: https://ultimatecourses.com/blog/angular-template-reference-variables

#angular 

Thierry  Perret

Thierry Perret

1657353600

Comment Utiliser Les Variables De Référence De Modèle Dans Angular

Dans cet article, vous apprendrez à utiliser les variables de référence de modèle, souvent appelées «références de modèle», dans Angular.

Dans Angular, les composants ont une templatepropriété qui contient des éléments et d'autres composants. Une variable de référence de modèle est une fonctionnalité qui nous permet d'accéder à une partie de notre modèle.

Il peut s'agir d'un élément, d'un composant ou d'une directive. Les variables de référence de modèle sont intelligemment implémentées et peuvent être utilisées de différentes manières.

La première pourrait être d'exporter simplement une référence à un élément. Ici, nous pouvons attacher un #à un <input>et fournir un nom de variable (d'où la référence de modèle 'variable'):

<input type="text" #coffee>

Vous pouvez considérer cette syntaxe comme une "exportation". Nous exportons une référence à l'élément.

Cela signifie que nous pouvons maintenant accéder aux propriétés de cette variable de référence comme si elle nous avait été renvoyée via du JavaScript simple (pensez à ce que vous obtiendriez en utilisant document.querySelector('input')et c'est ce que nous avons ici) :

<input type="text" #coffee>

<p>{{ coffee.value }}</p>

Cela déconnecterait une chaîne vide coffee.valuecar nous n'en avons pas value. Notre coffeevariable nous donne directement un HTMLInputElement.

Pour que nous puissions voir la valeur au fur et à mesure que nous tapons, nous aurions besoin d'introduire la ngModeldirective :

<input type="text" ngModel #coffee>

<p>{{ coffee.value }}</p>

Essayez-le et tapez quelque chose dans le <input>:

https://stackblitz.com/edit/angular-ivy-t3y6jt?file=src%2Fapp%2Fapp.component.ts

Voici donc la prochaine grande fonctionnalité des références de modèles.

Exportons une référence vers notre ngModelet changeons le contexte de ce qui #coffeenous renvoie.

En spécifiant #coffee, nous laissons implicitement Angular décider quoi exporter, car nous ne spécifions rien d'autre que la liaison à l'élément.

Nous relions ngModel, qui fait désormais « partie de » notre <input>. Exportons-le :

<input type="text" ngModel #coffee="ngModel">

<p>Value: {{ coffee.value }}</p>
<p>Pristine: {{ coffee.pristine }}</p>
<p>Touched: {{ coffee.touched }}</p>

En passant #coffee="ngModel", nous lions explicitement une référence à notre ngModeldirective suivie.

Nous n'avons plus de HTMLInputElement. Nous avons une référence à NgControl.

Vous pouvez vérifier le code source de NgControl ici, qui étend les classes NgControl et AbstractControlDirective .

Pourquoi regardons-nous cela? Parce qu'il vous montre toutes les propriétés disponibles pour vous, c'est exactement pourquoi nous avons référencé non seulement valuemais pristineaussi touched.

Essayez-les ci-dessous, notre variable de référence de modèle reflète lengModel :

Nous pouvons approfondir cela et accéder à une référence de modèle à l'intérieur d'un composant , afin que nous puissions accéder aux propriétés et aux méthodes à l'intérieur du classet pas seulement du template.

https://stackblitz.com/edit/angular-ivy-jwci6u?file=src%2Fapp%2Fapp.component.ts

Ceci est réalisé grâce à l'aide peut -être TemplateRefou ElementRefaux côtés d'un @ViewChilddécorateur. Lisez l'article ci-dessus sur la façon de le faire et un travail plus approfondi, mais cela ressemble essentiellement à ceci :

@Component({...})
export class AppComponent {
  @ViewChild('username') input: ElementRef<HTMLInputElement>;
}

C'est une bonne introduction aux références de modèles, et j'espère que cela vous permettra de mieux comprendre comment les utiliser, quand et où. Non seulement cela, mais à quoi s'attendre lorsque vous déclarez une référence de modèle et comment exporter également des références à des éléments tels que des directives.

Bon reffing ! 

Source : https://ultimatecourses.com/blog/angular-template-reference-variables

#angular 

Iara  Simões

Iara Simões

1657363500

Como Usar Variáveis ​​de Referência De Modelo Em Angular

Neste post você aprenderá a usar variáveis ​​de referência de modelo, muitas vezes conhecidas como “Referências de modelo”, em Angular.

Em Angular, os componentes possuem uma templatepropriedade, que contém elementos e outros componentes. Uma variável de referência de modelo é um recurso que nos permite obter acesso a uma parte de nosso modelo.

Isso pode ser um elemento, componente ou pode ser uma diretiva. As variáveis ​​de referência de modelo são implementadas de maneira inteligente e podem ser usadas de várias maneiras.

A primeira pode ser simplesmente exportar uma referência a um elemento. Aqui podemos anexar a #a an <input>e fornecer um nome de variável (daí a referência do modelo 'variable'):

<input type="text" #coffee>

Você pode pensar nessa sintaxe como uma “exportação”. Estamos exportando uma referência ao elemento.

Isso significa que agora podemos acessar as propriedades dessa variável de referência como se ela fosse retornada para nós por meio de JavaScript simples (pense no que você voltaria usando document.querySelector('input')e é isso que temos aqui):

<input type="text" #coffee>

<p>{{ coffee.value }}</p>

Isso desconectaria uma string vazia coffee.value, pois não temos value. Nossa coffeevariável está nos dando diretamente um HTMLInputElement.

Para vermos o valor enquanto digitamos, precisaríamos introduzir a ngModelDiretiva:

<input type="text" ngModel #coffee>

<p>{{ coffee.value }}</p>

Experimente e digite algo no <input>:

https://stackblitz.com/edit/angular-ivy-t3y6jt?file=src%2Fapp%2Fapp.component.ts

Então aqui está o próximo grande recurso das referências de modelo.

Vamos exportar uma referência para o nosso ngModele mudar o contexto do que #coffeenos retorna.

Ao especificar #coffee, estamos implicitamente deixando o Angular decidir o que exportar, porque não estamos especificando nada além de vincular ao elemento.

Estamos vinculando ngModel, que agora é 'parte' do nosso <input>. Vamos exportá-lo:

<input type="text" ngModel #coffee="ngModel">

<p>Value: {{ coffee.value }}</p>
<p>Pristine: {{ coffee.pristine }}</p>
<p>Touched: {{ coffee.touched }}</p>

Ao passar #coffee="ngModel", estamos vinculando explicitamente uma referência à nossa ngModeldiretiva rastreada.

Não temos mais HTMLInputElement. Temos uma referência a NgControl.

Você pode verificar o código-fonte do NgControl aqui, que estende as classes NgControl e AbstractControlDirective .

Por que estamos olhando para isso? Porque ele mostra todas as propriedades disponíveis para você, e é exatamente por isso que referenciamos não apenas , valuemas pristinee touchedtambém.

Experimente-os abaixo, nossa variável de referência de modelo está espelhando o ngModel:

Podemos aprofundar isso e acessar um template ref dentro de um componente , para que possamos acessar propriedades e métodos de dentro do classe não apenas do template.

https://stackblitz.com/edit/angular-ivy-jwci6u?file=src%2Fapp%2Fapp.component.ts

Isso é conseguido usando talvez TemplateRefou ElementRefao lado de um @ViewChilddecorador. Leia o artigo acima sobre como fazer isso e um trabalho mais profundo, mas essencialmente se parece com isso:

@Component({...})
export class AppComponent {
  @ViewChild('username') input: ElementRef<HTMLInputElement>;
}

Essa é uma boa introdução às referências de modelo, e espero que dê a você uma compreensão mais profunda de como usá-las, quando e onde. Não apenas isso, mas o que esperar quando você declarar um template ref e como também exportar referências para coisas como diretivas.

Feliz refrão! 

Fonte: https://ultimatecourses.com/blog/angular-template-reference-variables

#angular