I am learning AngularJS and trying to make sime redirecting application. I have index.html with dxTreeView (using devExtreme components). My goal is to load different view on click at item in the TreeView menu.
here is example of my index.html:
<body class="dx-viewport">
<div class="container" ng-app="MainContainer" ng-controller="MainController">
<div class="left-content">
<div id="simple-treeview" dx-tree-view="treeViewOptions"></div>
</div>
<div class="right-content">
<div data-options="dxView: {name: 'mainView', title: 'Main View'}" id="right-view">
</div>
</div>
</div>
index.js:
MainApp.controller("MainController", function MainController($scope) {
$scope.treeViewOptions = {
dataSource: treeLoginOption,
selectionMode: "single",
selectByClick: true,
displayExpr: "name",
keyExpr: "name",
onItemClick: function (e) {
var viewType = e.itemData.type;
if (viewType == "Login") {
$("#right-view").load("../views/" + viewType + ".dxview");
LoginController(); !!!!Here is my problem !!!
rebuildMenu();
}
else
{
$("#right-view").load("../views/" + viewType + ".html");
}
}
} });
What I need is to call another html page, which have .js file with another controller. With my approach, the page is called but not the .js file with controller.
Login.html:
<div class="form" ng-controller="LoginController">
<div class="dx-fieldset">
<div class="dx-fieldset-header">Přihlášení uživatele</div>
<div class="dx-field">
<div class="dx-field-label">Jméno</div>
<div class="dx-field-value">
<div dx-text-box="textBox.name" id="textBox.name"></div>
</div>
</div>
<div class="dx-field">
<div class="dx-field-label">Heslo</div>
<div class="dx-field-value">
<div dx-text-box="textBox.password" id="textBox.password"></div>
</div>
</div>
</div>
</div>
and Login.js:
MainApp.controller('LoginController', function ($scope) {
console.log("Login page generate called.");
$scope.textBox = {
name: {
placeholder: "Jméno",
visible: true
},
password: {
placeholder: "Heslo",
mode: "password",
visible: true
}
}; });
I would realy like your help. Thanks in advice.
For routing in angularJS you should use the angular-route
package. You can read more about it here on the AngularJS docs