I'm trying to develop an EmberJS application with ASP.NET MVC. I've found the SPA Template (thanks for developers, it's awesome!), but I want to do a different approach. Instead the SPA (Single-Page Application) approach, I want to use the ASP.NET routes and pages, like a commmon ASP.NET MVC app. The issue is: I want in every new page I can add a <script>
tag referencing the controller will be used in that page, you know?
Something like that:
The shared page contains the main references to EmberJS (app.js contains the initialization of EmberJS):
<html>
<head>
...EmberJS reference blahblah...
</head>
...
<body>
@RenderBody()
</body>
<script type="text/javascript" src="@Url.Content("~/Scripts/EmberJS/app.js")" />
</html>
Well, let's suppose I'll create a Customer page. I know I have to create a CustomerController to handle the page. Let's suppose too I'll create a CustomerController.js
file.
App.CustomerController = Ember.Controller.extend({
customers: [],
...
});
Then, I'll create a Customer.cshtml
, which will be the page to display the actions about Customers. I want to do something like this above:
<ul>
{{#each customer in controller.customers}}
<li>{{customer.name}}</li>
{{/each}}
</ul>
...
<script type="text/javascript"
src="@Url.Content("~/Scripts/EmberJS/Controllers/CustomerController.js")" />
So, I'll need a way to synchronize this Controller I've added with the <script>
tag to my page and make the controller understandable to the page.
Thanks you, guys!
Ember is specifically designed for creating Single Page Apps. If you don't want to create a SPA you should probably look at using something other than Ember.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.