Step 4: Passing Data Controller to Views and display those in the view
Complete Application using Grails 3
Created by :
Grails
tutorial
Programming, Software and application
1090
2020-10-14 16:12:27
You can pass data controller to views in different way. Suppose you have an array or object as like
def page_title = 'Home page'
def page_description = 'Welcome to "Complete Application using grails 3.x" Part 1'
render(view: "index", model: [page_title: page_title, page_description: page_description])
This data should be an array with key / value pairs. Inside your view, you can then access each value using its corresponding key, such as ${key}. In this index page, we can see this data as following :
<div class="jumbotron"> <h1> ${page_title}</h1> <p>${page_description}</p> </div>
Same way, you can pass object and other data which you want to.