简体   繁体   English

AngularJS-如何使用.js调用另一个HTML页面

[英]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.

相关问题 JS功能(Ionic,AngularJS)后重定向到另一个HTML页面-Cordova - Redirect to another html page after JS function (Ionic, AngularJS) - Cordova 我如何在另一个文件 js ANGULARJS 中调用函数 js - how can i call function js in another file js ANGULARJS 如何从另一个HTML页面调用表 - How to call table from another HTML page 如何从另一个HTML页面调用函数? - How to call a function from another HTML page? 如何将一个JavaScript元素调用到另一个HTML页面 - How to call a javascript element to another html page 如何在另一个HTML页面中的一个HTML页面中调用函数 - How to call a function in one html page in another html page 如何从angularjs中的另一个page2(service2.html)控制器(ctrl2)调用page1(service1.html)控制器(ctrl1)的函数 - how to call function of page1(service1.html) controller( ctrl1 ) from another page2(service2.html) controller( ctrl2 ) in angularjs 在html页面中调用externalinterface js - call externalinterface js in a html page 从AngularJS中的控制器在HTML页面上调用函数 - Call function on html page from controller in AngularJS 如何使用AngularJS中的自定义指令将一个html页面插入另一个html页面? - How to insert one html page into another html page using custom directive in AngularJS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM