簡體   English   中英

如何在另一個頁面(角度)中包含html頁面

[英]How to include html page in another page (angular)

我有這個頁面:

http://www.interload.co.il/upload/5798737.jpg

當我將“創建”頁面用作不同的html頁面時,它可以正常工作,但是當我將其包含在主頁中時,它將不起作用。

我嘗試了以下代碼:(只是包含事項的最后一行)

 <!DOCTYPE html> <html> <head> <meta charset="windows-1255"> <title>Insert title here</title> </head> <body> <table border="1"> <tr> <th>id</th> <th>name</th> <th>password</th> <th>email</th> <th>actions</th> </tr> <tr ng-repeat="c in g.companies"> <td>{{c.id}}</td> <td>{{c.name}}</td> <td>{{c.password}}</td> <td>{{c.email}}</td> <td><button data-ng-click="g.deleteCompany($index)">X</button> <button name="update" ng-click="g.showUpdateCompany()">O</button></td> <td ng-show="g.show"> Company id: <input value="{{c.id}}" disabled="disabled"><br/> Company name: <input value="{{c.name}}" disabled="disabled"><br/> Company password: <input ng-model="c.password"><br/> Company email: <input ng-model="c.email"><br/> <button ng-click="g.hideUpdateCompany(c)">Save</button> </td> <!--replace $index with c (the company)--> </tr> </table> <div ng-include src="'createCompany.html'"></div> </body> </html> 

這是我要包括的頁面:

 <!DOCTYPE html> <html> <head> <meta charset="windows-1255"> <title>Insert title here</title> </head> <body> <h2>Create new Company:</h2> Company ID: <input type="text" ng-model="c.newCompany.id"> <br> Company name: <input type="text" ng-model="c.newCompany.name"> <br> Company password: <input type="password" ng-model="c.newCompany.password"> <br> Company email: <input type="email" ng-model="c.newCompany.email"> <br> <button ng-click="c.createCompany()">Sumbit</button> <br> <p ng-show="c.success"> Company Added Successfully ! </p> <p ng-show="c.failure"> Company Failed to be added ! </p> </div> </body> </html> 

控制台設置在此處(用戶界面視圖):

 /** * */ var app = angular.module("myApp", [ "ui.router" ]); app.config([ '$locationProvider', function($locationProvider) { $locationProvider.hashPrefix(''); } ]); app.config(function($stateProvider, $urlRouterProvider) { $stateProvider .state("main", { url : "/main", templateUrl : "../HTMLs/AdminMain.html", }) .state("getCompanies", { url : "/getCompanies", templateUrl : "../HTMLs/getCompanies.html", controller : "getCompaniesCTRL as g" }) .state("createCompany", { url : "/createCompany", templateUrl : "../HTMLs/createCompany.html", controller : "createCompanyCTRL as c" }) .state("404", { url : "/404", templateUrl : "../HTMLs/404.html" }); $urlRouterProvider.when("", "/main"); // first browsing postfix is empty // --> route it to /main $urlRouterProvider.otherwise('/404'); // when no switch case matches --> // route to /404 }); 

ng-include的正確語法是這樣的:

<div ng-include src="updateCompany.html"></div>

要么

<ng-include src="updateCompany.html"></ng-include>

要么

<ng-include src="'updateCompany.html'"></ng-include>

要么

<div ng-include src="'updateCompany.html'"></div>

希望對您有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM