I recently started to learn Angularjs 2, I don't have much experience in Angular 1 and I'm following their docs.
I need to write in brazilian portuguese and I usually insert a charset of iso-8859-1 in my HTML's head. When I used my html in Angular structure the charset wasn't recognised anymore.
This is the example that I'm using to test. When I use this html in the Angular template or its main index the charset is not recognised.
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="iso-8859-1">
<title>João Paulo's site</title>
</head>
<body>
<h1>João Paulo</h1>
<h2>áéíóú ÁÉÍÓÚ çõ</h2>
</body>
</html>
The problem is solved despite I'm not sure why. As my page was evolving I started to load the page's content by a external json file.
I'm still confused about utf-8 and iso-8859-1, but what solved the problem was to let the html page charset as utf-8 and I had to save the json file as iso-8859-1.
Related
This questions is pretty specific to the react-starter-kit, though, someone else may be able to help here on the internets. I am trying to use the react-starter-kit with a flask application I am developing. I chose this yeoman generator as it had a lot of things I am looking for, though, I don't want to run on a node server. I have a flask app that I would just like to wire up to the react front end. I can't quite figure out how the node routes know which .js bundled file to include (and Node routes are a bit confounding to me anyways). Where would be the best place to start here?
I think if I could start with a specific question, to what .js file could I have an index.html point to? Or how can I find that?
I am tentative to ask this question here, but I hopefully will be directed to the right place.
Here is my index.html:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Flask React</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- styles -->
</head>
<body>
<div id="app"></div>
<!-- scripts -->
<script type="text/js" src="build/assets.js"></script>
</body>
</html>
Here is my flask view:
#CORE.route('/', methods=['GET'])
def index():
return render_template('index.html')
Here is the build/assets.js
module.exports = {"main":{"js":"/main.js?032d72b634c91d2f8756"}};
Where the /main.js?{{string}} points the that bundled version of the app.
Here is the file directory layout:
App
|-app
|-Core
|-view.py
|-Templates
|-index.html
|-build
|-assets.js
|-src
What I have decided to do, and what I would recommend doing, is to use Graphene and Flask-GraphQL alongside the react-starter-kit. Then to get to my data I can just have the node server query to the flask server to get the data from postgres. This will allow me to still to data-y things in python with the flask server and produce a RESTful API if needed, but will allow me to benefit from the awesomeness of GraphQL.
I am still getting everything figured out, and I will come back to repost in the future when I get things working all the way.
I've generated a Spring Boot application by using Spring Initializr. This is the screenshot of my resources directory.
I added Angular dependencies by using <script> tag in index.html
<!DOCTYPE html>
<html lang="en" ng-app="companyApp">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-resource.min.js"></script>
<script src="app.js"></script>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hello, Spring!
</body>
</html>
My main application class is configured with #SpringBootApplication annotation.
Once I open the page, I get this error in the console
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.0/$injector/modulerr?p0=companyApp&p1=Error…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.0%2Fangular.min.js%3A20%3A449)
From documentation I see that some module failed to load.
Should I include any other libraries in the index.html page to fix this error?
Solved the issue. Just use Bower to download needed dependencies and add them to /static directory.
Include in index.html
<!DOCTYPE html>
<html lang="en">
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/angular-resource/angular-resource.min.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="app/app.js"></script>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body ng-app="companyApp">
Hello, Spring!
</body>
</html>
if you want to split your static contents in many ways:
put them separately on apache/nginx server then it will access your spring boot application throw REST, but with different IP "if different machine" or Port "on same machine".
spring boot application can get static content outside its fat jar if you put the in /static folder in same path of your fat jar file, and you can change this path in application.properties using spring.resources.staticLocations property check here
finally you can make jar project to contains your static contents and add this project using maven as dependency to your spring boot project, do not forget your static contents have to be in /resources/static
which option to use based on you case and you project size but it is recommended to split it if you have different developers working on front/back end.
Just add AngularJS using Spring Initializr and it will do it all for you, or do it separately and copy how it generates the front-end layout. I personally have resources -> static -> app then have all of my partials within 'app', index.html under 'static' and application.properties under 'resources'.
I followed the instruction on jetBrains to Installing AngularJS Manually. 1.4.x stable
Created a folder and drag it to the WebStorm icon on my El Capitan dock.
Right click on the folder and created a new file and named it index.html
Added the ng-app directive to bootstrap the application to the html element.
Trying to get the context assist to help resolve the link to angular.js file which is located as a sibiling to the folder I created in step 2 above but do not see it in the list after hitting ^Space twice.
So I just typed it by hand
<!doctype html>
<html lang="en" ng-app>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="/../angular.js"></script>
</head>
<body>
Name: <input ng-model="username"/>{{username}}
</body>
</html>
But Chrome is showing the Binding with the expression inside it instead of evaluating it.
What am I doing wrong? Thanks
This JSFiddle works
<body ng-app>
Name: <input ng-model="username"/>{{username}}
</body>
so my assumption is that your reference to angular.js isn't being loaded in the browser because it is incorrect. You will need to link to a CDN for angular or place the angular.js file somewhere under your project directory. See the following for why External Libraries will not work as a reference. WebStorm: How can I link the HTML to an installed JS library?
I am newly picking up angularJS, cannot figure out my situation here:
Everything goes fine when I just open official phonecat tutorial file.
However, if I create my own project, the binding never displays well, it also shows out "{{ }}".
Pictures show all I got here. I believe nothing wrong with the script referencing, just cannot figure out after tried hundred times.
It seems script referencing is not correct. Make sure that your script reference is correct.
I run the following code and it gave me the expected result.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body data-ng-app>
<p>{{1+2}}</p>
</body>
</html>
See Demo
In the browser check the source. Does angular exist in your browser.
I took a freshly-cloned copy of the Boomerang library and ran make to produce the default boomerang.js script.
I copied that file, along with the following HTML document into a directory.
<html>
<head>
<script src="/boomerang.js" type="text/javascript"></script>
<script type="text/javascript">
BOOMR.init({
user_ip: "127.12.34.56",
beacon_url: "http://127.0.0.1:8008/beacon",
beacon_type: "POST"
});
</script>
</head>
<body>
<h1>Hello RUM</h1>
</body>
</html>
I then served that out of host running on port 8008 and viewed the html file. When I check the access log, I see
127.0.0.1 - - [17/May/2016:15:13:31 +0200] "GET /beacon?u=http%3A%2%2F127.0.0.1%3A8008%2Frum.html&v=0.9&...
That is, the Boomerang library is issuing a GET instead of POST and at a quick glance I can't figure out why. (The /beacon endpoint doesn't actually exist, so it throws a 404, but that is (I hope) beside the point). I'll take a closer look with dev tools, but has anyone experienced this before?