I implemented AngularJS: MVC structure in my web application.
My project is the following structure.
-Package
|_app
|_build
|_home
|_controllers(HomeCtrl.js)
|_modules(HomeResources.js)
|_views(home.html)
|_module.js
|_bower_components(all javascript libraries are here)
|_app.scripts.json
|_bower.json
|_gulpfile.js
|_index.html
I used gulp to build the project and try to load home's home.html into index.html. After building using gulp, I have app.js inside build folder and load into index.html as follow.
index.html
<!DOCTYPE html>
<html lang="en-us" class="no-js">
<head>
<meta charset="utf-8">
<title>BnLMyanmar</title>
<meta name="description" content="">
<meta name="author" content="">
</head>
<body>
<script src="build/vendor.js"></script>
<script src="build/app.js"></script>
</body>
</html>
But contents of home.html are not displayed on the webpage when the application is run.
The full source code can be viewed here .
Why I can't display the contents of home.html at the home page?
Thanks
Related
My files are in entirely separate folders. I'm attempting to call CSS and JS files from a different path. Example below:
mainDirectory\internal\scripts\main.js
mainDirectory\internal\styles\main.css
mainDirectory\internal\pages\homePage.html -- (main page file)
I want to do this without libraries.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Test</title>
<link rel="stylesheet" href="../folderThree\test.css">
<script src="../folderTwo/test.js" type="text/javascript"></script>
</head>
<body>
<p>Test</p>
</body>
</html>
I was able to determine that I made a syntax mistake here, as I'm used to a different system. Turns out that all I needed ../ and to swap my slashes from back to forward.
Is there any decent procedure to compile html, css, and js files into one js file? I've been looking on methods how to load css and html files to js, and they all require requireJS. Is there any webpack plugin, or just a module for this?
I know this is not a decent question, but I've been thinking on not always fetching an external source file (html, css).
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Blah blah blah</title>
<script src="something.js"></script>
<script>
// 'load' will load everthing to #something
something.load(
// options
)
</script>
</head>
<body>
<div id="something"></div>
</body>
</html>
Finally, thanks to this article, all I need is html-loader. Then I can just add import html from 'some.html'.
I have on one side an existing website, on the other I have an Angular 7 application component.
I'd like to edit my existing someusecase.html and reuse my Angular 7 application like so e.g.
<html lang="en">
<head>
<meta charset="utf-8">
<title>How to import Angular 7 App?</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<app-root></app-root>
</body>
</html>
What would I need to include in the html for this to work? I'm after e.g. something equivalent to:
<script src="/ui/node_modules/angular/angular.min.js"></script>
<script src="/ui/components/Application.js"></script>
In other words, is it possible to reuse and activate an Angular 7 Application within a <div> scope inside an existing webpage?
1) Run
ng build
2) got into the dist folder
3) Copy & paste all of the files there, to your original app, except for the index.html file.
4) Open the not-copied index.html file
5) Copy all of the <script> tags in this file, into your someusecase.html file, at the same spot.
6) use your app component selector wherever you want your angular application to be displayed.
Note that this is only informational : in real life, this should be automated, because you would have to do this manipulation on every build.
I'm starting on a project using netbeans. I created a Web Page Project and its default .html is called "index". In index.html directory, it has a folder called "WEB-INF". I created a new folder inside of it and call it JavaScripts. Then I created a JS file inside that JavaScripts folder.
Below is my html and JS:
html:
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="WEB-INF/JavaScripts/index.js"/>
</head>
<body>
</body>
</html>
JS:
document.write("testabc");
Its a very simple JS code but nothing appearing on my browser. How can I properly link JS(from different folder) to HTML? Thanks in advance.
I work with Netbeans 8.2 and I created a Web Application. I have a html and a js.
The html is
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
<script type="text/javascript" src="js1.js"></script>
</body>
</html>
The project's structure is
I want to include the js1.js.
When I run the application in the browser's console I get a 404
GET http://localhost:8080/Prueba/js1.js [HTTP/1.1 404 Not Found 2ms]
Why do I get this 404?
file js1.js has to be inside the web directory(in netbeans) and not outside as you show in the image