<p>Not sure exactly what you trying to do here?  Call a Twig template from Angular?</p>

<p>Twig is a server side technology, Angular is getting parsed on the client side. The only way Craft is going to parse a Twig template is when it encounters a URL. </p>

<p>Instead of calling the Twig template directly, you call the URL, which <a href="https://craftcms.com/docs/routing">could match a template</a>. Inside <code>templates</code>, make a folder like <code>angular-views</code> and then inside that put a file called <code>md-dialog.twig</code>.  From the front end, now you can call it from Angular like <code>http://example.com/angular-views/md-dialog</code> (the .twig is optional).</p>

<p>If you're trying to use Angular inside of a Twig template, you may want to use something like <a href="http://twig.sensiolabs.org/doc/tags/verbatim.html"><code>{% verbatim %}</code></a> and then put your JS/Angular templating between those tags to make sure Twig doesn't touch any of it. </p>

CC BY-SA 3.0
2016-01-16T12:01:43.063Z
I wanted to call a Twig template from a Twig template from within `<script type="text/javascript"></script>` tags. So I built the path to a file, which was in a folder  with underscore("_"). That was my mistake, as It didn't occur me right away, that folders/files are hidden from direct access with underscore at the beginning.  So It was throwing me a status of `404`. Than I tried Twig's tags `{% included %}`,`{% embed %}` and `{% verbatim %}` which gave me an AngularJS error. Glad you turned in on me with your answer.
Dominik Krulak
CC BY-SA 3.0
2016-01-16T20:41:01.053Z
Good deal - glad it was helpful!
RitterKnight
CC BY-SA 3.0
2016-01-15T20:45:41.933Z
2016-01-15T20:45:41.933Z
RitterKnight
<p>I'm trying to call for a Twig template <code>_template</code> from a Twig template, particularly from within AngularJS <code>&lt;script type="text/javascript"&gt;&lt;/scirpt&gt;</code> tags. A console log says, that the file was not found on the server with status of 404. Using <code>{% include '' %}</code> or <code>{% embed '' %}</code>interferes with AngularJS somehow. Does any way around exists to access that Twig template, without breaching the security?</p>

<p>Troubleshooting part of js:</p>

<pre><code>$mdDialog.show({
  templateUrl: '_template',
})
</code></pre>

CC BY-SA 3.0
2016-01-15T00:46:18.830Z
Can you give me a general idea of what's hanging out in the file.twig? Also- what issues is it giving you with the include/embed tags?
Dustin C
CC BY-SA 3.0
2016-01-15T07:04:30.030Z
The console log says that an error is coming from angularjs. The file.twig has entries and some math to get a reviews and ratings work. It's working fine without including template path within script tags. So I thought maybe to hardcode the path?
Dominik Krulak
<routing>
Direct access call for a twig template from a twig template gives 404
# Direct access call for a twig template from a twig template gives 404

(Asked by: username_0 on 2016-01-14)

I'm trying to call for a Twig template `_template` from a Twig template, particularly from within AngularJS

**Tags:** routing

> **Comments:**
> **username_1**: Can you give me a general idea of what's hanging out in the file.twig? Also- what issues is it giving you with the include/embed tags?  
> **username_0**: The console log says that an error is coming from angularjs. The file.twig has entries and some math to get a reviews and ratings work. It's working fine without including template path within script tags. So I thought maybe to hardcode the path?  

---

## 1 answers

### Answer by username_2 on 2016-01-15. Score: 5 | Accepted answer

Not sure exactly what you trying to do here? Call a Twig template from Angular?

Twig is a server side technology, Angular is getting parsed on the client side. The only way Craft is going to parse a Twig template is when it encounters a URL.

Instead of calling the Twig template directly, you call the URL, which [could match a template](https://craftcms.com/docs/routing). Inside `templates`, make a folder like `angular-views` and then inside that put a file called `md-dialog.twig`. From the front end, now you can call it from Angular like `http://example.com/angular-views/md-dialog` (the .twig is optional).

If you're trying to use Angular inside of a Twig template, you may want to use something like [`{% verbatim %}`](http://twig.sensiolabs.org/doc/tags/verbatim.html) and then put your JS/Angular templating between those tags to make sure Twig doesn't touch any of it.

> **Comments:**
> **username_0**: I wanted to call a Twig template from a Twig template from within `<script type="text/javascript"></script>` tags. So I built the path to a file, which was in a folder  with underscore("_"). That was my mistake, as It didn't occur me right away, that folders/files are hidden from direct access with underscore at the beginning.  So It was throwing me a status of `404`. Than I tried Twig's tags `{% included %}`,`{% embed %}` and `{% verbatim %}` which gave me an AngularJS error. Glad you turned in on me with your answer.  
> **username_2**: Good deal - glad it was helpful!  

---

