我从链接下载源代码并试图了解它们如何相互链接。我不熟悉html,css,js等Web应用程序工具。所以我很难理解。
文件夹结构
-public_html
|_index.html
|_home
|_controllers
|_HomeCtrl.js
|_views
|_home.html
|_module.js
index.html已
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Basic Styles -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="styles/fonts/line-icons/line-icons.css">
<!-- Bootstrap CSS -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/jasny-bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/material-kit.css">
<!-- Main Styles -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/main.css">
<!-- custom Styles -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/custom.css">
<!-- Responsive CSS Styles -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/responsive.css">
<!-- Slicknav js -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/slicknav.css">
<!-- Bootstrap Select -->
<link rel="stylesheet" type="text/css" media="screen" href="styles/css/bootstrap-select.min.css">
<link rel="shortcut icon" href="styles/img/favicon/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="styles/img/splash/sptouch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="76x76" href="styles/img/splash/touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="120x120" href="styles/img/splash/touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="152x152" href="styles/img/splash/touch-icon-ipad-retina.png">
<!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- Startup image for web apps -->
<!--
<link rel="apple-touch-startup-image" href="styles/img/splash/ipad-landscape.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
<link rel="apple-touch-startup-image" href="styles/img/splash/ipad-portrait.png" media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
<link rel="apple-touch-startup-image" href="styles/img/splash/iphone.png" media="screen and (max-device-width: 320px)">
-->
</head>
<body>
<div><?php include('/app/home/views/home.html'); ?></div>
</body>
</html>
HomeCtrl.js有
'use strict';
angular.module('app.home').controller('HomeController', function ($scope) {
});
home.html已
<!-- Start intro section -->
<section id="intro" class="section-intro">
<div class="overlay">
<div class="container">
<div class="main-text">
<h1 class="intro-title">Welcome To <span ><strong>Test</strong>Page</span></h1>
<p class="sub-title">Search for property, jobs and more</p>
<!-- Start Search box -->
<div class="row row-centered">
<div class="search-bar col-centered">
<div class="advanced-search">
<div class="row row-centered">
<div class="col-md-6 col-sm-6 col-xs-12 col-centered">
<button class="btn btn-common btn-search btn-block"><strong>Model</strong></button>
</div>
<div class="col-md-6 col-sm-6 col-xs-12 col-centered">
<button class="btn btn-common btn-search btn-block"><strong>Actress</strong></button>
</div>
</div>
<form class="search-form" method="get"></form>
</div>
<!-- </form> -->
</div>
</div>
<!-- End Search box -->
</div>
</div>
</div>
</section>
<!-- end intro section -->
<div class="wrapper">
<!-- Categories Homepage Section Start -->
<section id="categories-homepage">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3 class="section-title">Browse Ads from 8 Categories</h3>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-1 wow fadeInUpQuick" data-wow-delay="0.3s">
<div class="icon">
<a href="#"><i class="lnr lnr-store color-1"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Lady</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-5 wow fadeInUpQuick" data-wow-delay="1.5s">
<div class="icon">
<a href="#"><i class="lnr lnr-briefcase color-5"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Business</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-6 wow fadeInUpQuick" data-wow-delay="1.8s">
<div class="icon">
<a href="#"><i class="lnr lnr-graduation-hat color-6"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Men</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-7 wow fadeInUpQuick" data-wow-delay="2.1s">
<div class="icon">
<a href="#"><i class="lnr lnr-apartment color-7"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Kids</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-8 wow fadeInUpQuick" data-wow-delay="2.3s">
<div class="icon">
<a href="#"><i class="lnr lnr-car color-8"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Travel</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-2 wow fadeInUpQuick" data-wow-delay="0.6s">
<div class="icon">
<a href="#"><i class="fa fa-laptop fa-5x color-2" aria-hidden="true"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Actors</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-4 wow fadeInUpQuick" data-wow-delay="1.2s">
<div class="icon">
<a href="#"><i class="lnr lnr-cart color-4"></i></a>
</div>
<div class="category-header">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Shopping</h3></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="category-box border-3 wow fadeInUpQuick" data-wow-delay="0.9s">
<div class="icon">
<a href="#"><i class="lnr lnr-cog color-3"></i></a>
</div>
<div class="category-header ">
<a href="#"></a>
</div>
<div class="category-content row-centered">
<div class="category-body"><h3 class="col-centered">Services</h3></div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Categories Homepage Section End -->
</div>
<!-- Counter Section Start -->
<section id="counter">
<div class="container">
<div class="row">
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="counting wow fadeInDownQuick" data-wow-delay=".5s">
<div class="icon">
<span>
<i class="lnr lnr-tag"></i>
</span>
</div>
<div class="desc">
<h3 class="counter">12090</h3>
<p>Regular Ads</p>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="counting wow fadeInDownQuick" data-wow-delay="1s">
<div class="icon">
<span>
<i class="lnr lnr-map"></i>
</span>
</div>
<div class="desc">
<h3 class="counter">350</h3>
<p>Locations</p>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="counting wow fadeInDownQuick" data-wow-delay="1.5s">
<div class="icon">
<span>
<i class="lnr lnr-users"></i>
</span>
</div>
<div class="desc">
<h3 class="counter">23453</h3>
<p>Reguler Members</p>
</div>
</div>
</div>
<div class="col-md-3 col-sm-6 col-xs-12">
<div class="counting wow fadeInDownQuick" data-wow-delay="2s">
<div class="icon">
<span>
<i class="lnr lnr-license"></i>
</span>
</div>
<div class="desc">
<h3 class="counter">150</h3>
<p>Premium Ads</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Counter Section End -->
module.js有
"use strict";
angular.module('app.home', ['ui.router'])
.config(function ($stateProvider) {
$stateProvider
.state('app.home', {
url: '/home',
data: {
title: 'Blank'
},
views: {
"content@app": {
templateUrl: 'app/home/views/home.html',
controller: 'HomeController'
}
}
})
});
如果我将home.html的所有内容复制并包含在index.html中的body中,我可以看到主页。
但我只想使用<div><?php include(); ?></div>
包含文件名
我试图加入<div><?php include(/home/views/home.html); ?></div>
但没有任何结果。
有人可以解释我吗
(1)将文件夹拆分为控制器和家中的视图有什么好处?
(2)这些js文件的目的是什么,HomeCtrl.js和module.js?
(3)如何从index.html调用home.html?
由于
EDIT1:
我有另一个文件app.js
,它有
'use strict';
/**
* @ngdoc overview
* @name app [smartadminApp]
* @description
* # app [smartadminApp]
*
* Main module of the application.
*/
var app = angular.module('app', [
'ngSanitize',
'ngAnimate',
'restangular',
'ui.router',
'ui.bootstrap',
// Smartadmin Angular Common Module
'SmartAdmin',
// App
'app.auth',
'app.layout',
'app.consumers',
//'app.chat',
//'app.dashboard',
//'app.calendar',
//'app.inbox',
//'app.graphs',
//'app.tables',
//'app.forms',
//'app.ui',
//'app.widgets',
//'app.maps',
//'app.appViews',
//'app.misc',
//'app.smartAdmin',
//'app.eCommerce'
'app.home'
])
.config(function ($provide, $httpProvider, RestangularProvider) {
// Intercept http calls.
$provide.factory('ErrorHttpInterceptor', function ($q) {
var errorCounter = 0;
function notifyError(rejection) {
console.log(rejection);
$.bigBox({
title: rejection.status + ' ' + rejection.statusText,
content: rejection.data,
color: "#C46A69",
icon: "fa fa-warning shake animated",
number: ++errorCounter,
timeout: 6000
});
}
return {
// On request failure
requestError: function (rejection) {
// show notification
notifyError(rejection);
// Return the promise rejection.
return $q.reject(rejection);
},
// On response failure
responseError: function (rejection) {
// show notification
notifyError(rejection);
// Return the promise rejection.
return $q.reject(rejection);
}
};
});
// Add the interceptor to the $httpProvider.
$httpProvider.interceptors.push('ErrorHttpInterceptor');
RestangularProvider.setBaseUrl(location.pathname.replace(/[^\/]+?$/, ''));
})
.constant('APP_CONFIG', window.appConfig)
.run(function ($rootScope
, $state, $stateParams) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
// editableOptions.theme = 'bs3';
});
var httpApiConfig = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;',
headers: { 'Content-Type': 'application/json' },
}
};
app.constant('httpApiConfig', httpApiConfig)
答案 0 :(得分:1)
1 - 将文件夹拆分为控制器和家中的视图有什么好处?
层次结构的目标是(你几乎可以想要你想要的):
这是一种常见的模式,尝试搜索MVC&#39;模块/视图/控制器&#39;
2 - 这些js文件的目的是什么,HomeCtrl.js和module.js?
你必须学习AngularJS
此处module.js
是模块Home
的配置文件
它还包含此模块的路由。
HomeCtrl.js
是控制器,你必须在你的data
和UI
3 - 如何从index.html调用home.html?
首先,您必须在<script>
标记中加载所有JS文件
然后你的身体必须看起来像这样
<body ng-app="app">
<div ui-view="content"></div>
<!-- put below all of you js files -->
<!-- angular.js / main.js /app.js / controllerFiles.js etc ... -->
</body>
答案 1 :(得分:1)
根据函数名称,似乎您正在使用angularJS。
模型/视图/控制器是一种允许程序员/设计师专注于他们最擅长的方法,他们不需要知道系统中的所有内容 进行修改和开发。
简要说明 (并不总是正确的,因为术语MVC已经有很多解释)
模型/控制器:后端(服务器端)的东西。 视图:设计用户实际看到的界面。它显示控制器提供的变体和信息,或将用户输入传递给控制器以执行某些操作。
在这种情况下,
网页设计师只需要做UI和CSS部件,当他们需要数据库中的东西时,他们只需在HTML / CSS / JS中添加标签。
相比之下,代码/后端开发人员不必关心如何构建漂亮的UI,而只需要专注于输出必要的字符串到前端。
阅读与&#34;模型 - 视图 - 控制器&#34;相关的文章。应该帮助你更好地理解他们是如何以及为什么这样做的。
答案 2 :(得分:1)
好的,我会回答你,但会将部分答案作为链接提供,因为听起来你真正需要的是阅读有关主题的内容。
首先,将index.html更改为index.php,并在需要时更改标记;当你把它放到一个html文件中时,服务器无法识别(除非你修改htaccess文件,而只是把它变成一个php文件)。
将代码拆分为不同的文件夹/类的优点是,对于了解MVC架构的人(您可以在fx维基百科上找到它的内容的介绍)变得更加清晰,其中放置了什么功能。在我看来,你正在帮助自己学习it的基础知识。虽然它最初是为Java开发的,但它在Web开发中的应用却有些争议。 MVC架构/模式也有助于促进低耦合和高内聚。
.js文件的作用......好吧,在我看来它最初似乎是在使用Angular.js(一个框架),但我找不到包含我期望它的地方。但是如果你想学习一点使用Angular,你可以这样做here。