[英]AngularJS - how to call another html page with .js
I am learning AngularJS and trying to make sime redirecting application. 我正在学习AngularJS,并尝试制作sime重定向应用程序。 I have index.html with dxTreeView (using devExtreme components).
我有dxTreeView(使用devExtreme组件)的index.html。 My goal is to load different view on click at item in the TreeView menu.
我的目标是单击TreeView菜单中的项目以加载不同的视图。
here is example of my index.html: 这是我的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: 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. 我需要调用另一个html页面,该页面具有另一个控制器的.js文件。 With my approach, the page is called but not the .js file with controller.
用我的方法,将调用该页面,但不会调用带有控制器的.js文件。
Login.html: 的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: 和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. 要在angularJS中进行路由,应使用
angular-route
软件包。 You can read more about it here on the AngularJS docs 您可以在AngularJS文档中阅读有关此内容的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.