I am developing a web application for a game using MVC but the views are different (there is a CreateGameView, a GameView ...) meaning there is not a shared navigation bar. I am using AngularJS.
I am not sure about how to make that the Views use the Controllers or other Views.
For instance I have a View called CreateGameView.html. When user push a button of this page, I want the page to call some Controller function and then load another View called GameView.html. GameView.html displays other buttons and use other Controllers.
This is my code for CreateGameView.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MyGame</title>
<link rel="stylesheet" href="http://ift.tt/2baqkoF">
<link rel="stylesheet" type="text/css" href="assets/css/CreateGameView.css">
<link href="http://ift.tt/1k4Fhr6" rel="stylesheet">
<script src="http://ift.tt/25QiOWS"></script>
<script src="http://ift.tt/1ZRkKr5"></script>
<script type="text/javascript" src="js/routes.js"></script>
</head>
<body ng-app="MyGame">
<div class="header-nightsky">
<nav class="navbar navbar-default">
<div class="container">
</div>
</nav>
<div class="hero" ng-controller="CreateNewGameController">
<h1>Create new game</h1>
<h3>which option do you prefer?</h3>
<div ng-click="createGameAsGuest()" class="btn btn-primary" role="button">Guest</div>
<div ng-click="createGameAsHost()" class="btn btn-primary" role="button">Host</div>
</div>
</div>
</body>
</html>
My questions:
-
Should I use the ng-app directive in each page?
-
Has any sense to use the AngularJS route module with no single page application instead simply using the ng-controller directive and a link to the controller the current View uses?
-
How can I pass argument to the same Controller function when clicking buttons instead using different functions?
-
When a button is pushed I want another View (another html page) to be loaded after the Controller function is called, should I perform the redirection inside the Controller function?
Aucun commentaire:
Enregistrer un commentaire