2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								# SVG as templates
 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								You can use SVG files as templates in your Angular applications. When you use an SVG as the template, you are able to use directives and bindings just like with HTML templates. With these features, you can dynamically generate interactive graphics.
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< div  class = "alert is-helpful" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								See the < live-example  name = "template-syntax" > < / live-example >  for a working example containing the code snippets in this guide.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								## SVG syntax example
 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The following example shows the syntax for using an SVG as a template.
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< code-example  path = "template-syntax/src/app/svg.component.ts"  header = "src/app/svg.component.ts" > < / code-example > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								To see property and event binding in action, add the following code to your `svg.component.svg`  file:
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								< code-example  path = "template-syntax/src/app/svg.component.svg"  header = "src/app/svg.component.svg" > < / code-example > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-19 17:39:33 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The example given uses a `click()`  event binding and the property binding syntax
							 
						 
					
						
							
								
									
										
										
										
											2020-04-28 16:26:58 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								(`[attr.fill]="fillColor"` ).