Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Angularjs single page app

Started by Muut Archive 11 years ago · 1 replies · 1223 views
11 years ago

Is there any plugin/documentation about adding angularjs applications inside grav? I mean: an html form with some custom tags and some javascript code...

Thanks
Matteo

11 years ago

You mention forms, so first I'll link to the Forms docs.

You can certainly provide an Angular app in a Grav theme, by adding the JS / markup needed.
The only issue you'll probably get into is Twig using the same brackets as Angular, if you define your app in Twig files, but there are solutions for this.

If you need Grav to provide data, you can create a JSON endpoint very simply, by having a (example) todos.json.twig file in your template, and have a page called todos.md under /user/pages/api/todos. Calling yoursite.com/api/todos.json will invoke such json.twig file. What you output there is up to you, you can iterate over some YAML defined inside the page, or build a plugin that exposes some objects to Twig, even calling from a DB, network call or whatever.

If you need to build a more advanced API, I once did this p roof of concept which can be a starting point: https://github.com/flaviocopes/grav-plugin-api. Development halted as we'll implement it in the core at some point.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 676 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5337 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago