Using HTML instead of ejs in sails - angularjs

I am a newbie on sails framework and I started working on it then found that everything is in ejs. When I converted it into the HTML then it didn't work.
How to write client-side in HTML using AngularJS without ejs or with least ejs possible if we cannot remove it totally.
Where to write client-side routes and how to use ui-router in that?

You should place your angular code in assets/js. The html files are also to be placed in assets folder.
I have set up a basic sails/ angular app in github. Angular Demo

Related

Where to put ng1 templates in an angular hybrid application built by angular-cli?

I'm trying to build an angular hybrid application out of a angular.js application. I'm following the official documentation (https://angular.io/guide/upgrade). I reached and completed this step: https://angular.io/guide/upgrade#bootstrapping-hybrid-applications.
I'm using angular ui-router 0.3.1 to handle the routing of my application. Therefore, using the config function on my main module, and the $stateProvider service, I've mapped each route to an angular.js controller and a template specified by the templateUrl parameter.
My application seems to startup correctly but the templates cannot be loaded because they cannot be found (404 error). This is normal because they are not imported in the dist folder where my application is built when I use the ng build angular-cli command line.
How can I configure my application so that my angular.js html templates get copied in the dist folder when my angluar application is built by angular-cli?
Thanks in advance!
So actually it appears my question was a duplicate of that one: Angular CLI with Hybrid app ng-build.
The idea is to use the assets array from angular-cli.json. Glob enables to select recursively all html files from the folder of your choice and to put them in a subfolder of dist:
"asssets": [{"glob": "**/*.html", "input": "../src-ng1", "output": "./src-ng1"}]

Where to define routes when working with laravel and angular JS project

I am working on project using laravel and angular JS. And I am a little bit confused, about where to use routes in angular so I can make a spa, or I should specify the folders and pages using route.php of laravel framework too.
Or should I configure them both ?
Please any help and sorry if I didn't post a code.

Play framework and Angular - Loading angular templates

I have an Angular app which I am serving from Play.
The main routes within Play all serve some HTML pages which contain ng-include statements to some angular templates which are in a "templates" folder in public...
<div ng-include="'#routes.Assets.versioned("templates/test.html")'"></div>
This works fine as I can use Play to reference the assets as normal. Now when the page loads in the browser, each of these templates load and in turn try to pull in further angular templates...
<div ng-include="'templates/test2.html'"></div>
But this results in a 404 as the "templates" folder cannot be resolved.
How can I have a truly public "templates" folder with Play where each of angular can pull in whatever templates it needs in the browser?
Thanks
You will need something like this in your PLAY routes file:
GET /templates/*file controllers.Assets.at(path="/public/templates", file)
In this link you can see the whole solution

How to integrate AngularJS with Expressjs & NodeJS ? How to replace Jade with angular?

I have jade as default templates and want to remove completely and use angular instead. How to do it ? How to remove Jade from the package ?
I want to use Plain HTML + Angular for creating frontend without ejs or any package.
Place this in your express app.js file or edit it if already present:
app.use('/', express.static(path.join(__dirname, '/your directory')));
remove any other lines like app.set(views... or app.set(view engine).
First, you need to set your view engine in your Express main app.js file to html.
app.set('view engine', 'html');
Remove all the configurations made in your app.js using
app.set
Now, we need to remove the Jade template engine module from our list of packages installed
npm uninstall jade
Now update your package.json file with
npm update -g
We have now set up our template engine as HTML and now we need to update our express app.js to point to directory for Angular js
Default we use Public directory
app.use(express.static(path.join(__dirname, 'public')));
Now place your Angular js code in public directory of your Express app.
Also, make sure to change the routes accordingly in Angular which will point to Express Node js routes defined as required by your app.
You don't need to use jade with angular.
You can still make html templates with angular in stead.
The way to do that is to create a tag in your html
like:
<your-tagname> </your-tagname>
then you create a simple directive inside your angular js code.
pl.directive('yourTagname', function(){
return {
restrict: 'E' ,
templateUrl: 'view/yourhtmlpagename.html'
};
});
This will load any html sniper/content inside your custum html tag.
If you don't create any jade files, that will be easily ignored.
Only make sure to point to your index.html and not index.jade in your express code if you use node.js.

Infinite loop between JSP and webpack + AngularJS app

We are trying to integrate a JEE app (jsp on the frontend) with an angularJs app. The angularJS is being packaged with webpack so in the jsp we are linking the app thru a <script> tag
The application is being manually bootstrapped once the modules are already defined.
The result once the manual bootstrapping occurs is kind of an infinite loop between the jsp and the angular app. We can see the url alternating between these two:
http://localhost:8080/app/initApplication?lang=ES&TOTAL_APPROVALS=1#_
http://localhost:8080/app/initApplication?lang=ES&TOTAL_APPROVALS=1#/
Note the / at the end of the second one.
The angular app sometimes get rendered in the browser and some others don't.
We think it has something to do with what occurs with $location when manually bootstrapping an Angular app but we really don't know.
What's going on?

Resources