Protractor: ng-binding what does the ng stand for - binding

I'm using protractor and locators like ng-bind and I got curious.
What does the "ng" stand for?
I did a bit of hunting and didn't find the definition.

I don't know much about protractor, but this might be related to Angular which has "ng" in front of a lot its functions. For example: ngFor, *ngIf, and ngClass.
Also a lot of 3rd party angular libraries use ng to denote that they are angular libraries. For example ng-bootstrap, ng-quill, and ng-score-polygon.
Note that ng was typically used for angularjs, ng2 and ngx were typically used for angular 2 and newer. Now ng is typically used for angular2 because angularjs is in long time support and not maintained.
If this is not related to some angular testing tool within protractor, then I'm not sure what it could stand for.

ng is short for A'ng'ular. I know, that it's not a great abbreviation but it is what it is. Since you are using Protractor, you must have come across additional locators like model, repeater etc, these utilises ng-model, ng-repeat. All built in functions of Angular uses this prefix.

The prefix ng stands for "Angular;" all of the built-in directives that ship with Angular use that prefix. Similarly, it is recommended that you do not use the ng prefix on your own directives in order to avoid possible name collisions in future versions of Angular.
From the FAQ:
Why is this project called "AngularJS"? Why is the namespace called
"ng"?
Because HTML has Angular brackets and "ng" sounds like "Angular".

Related

Angular 7 CLI build: how to omit templates to be able to use MVC views?

I'm evaluating the lastest bits of Angular (7+) and CLI. I've done parts of the 'Tour of Heroes' tutorial. I can run 'ng build' to get the production bits.
However, an important requisite is the use of MVC views for component templates.
So instead of
templateUrl: './app.component.html'
I want to use
templateUrl: '/Template/Index'
for various reasons (translated templates being one). I do understand this is not the 'pure' Angular way of doing thing.
With this code in place, 'ng build' no longer works:
ERROR in ./src/app/app.component.ts
Module not found : error : Can't resolve './/Template/Index' in 'D:\Angular\TourOfHeroes\TourOfHeroes\src\app'
I've searched for hours how to omit building the templates, but I can't find an answer. ng eject is depricated. It guides me to ngx-build-plus, but I don't see how this can help me.
What steps should I take to get this working?
EDIT:
Question How to using MVC views (*.cshtml) as templates in Angular 2? is not related. I know how to use MVC views in Angular. What I don't know is how to tell 'ng build' to omit these templates (as they are not static at all).
You might have to switch to webpack/rollup/systemjs-builder in order to create builds omitting baking in templates. Angular CLI doesn't support such scenario.
One caveat - you will be building in development mode, aot doesn't support dynamic templates (not in straightforward way)

Why does Angular not need a dash in component name

I wondered why Polymer elements need a dash in custom elements name like <my-component> while this is not necessary for Angular components especially as Angular components also use ShadowDOM.
** Edit**
It doesn't even seem to be suggested good practice in Angular.
The HTML spec allows you to use unknown tags (<tab>, <panel>) without the HTML parser throwing a fit. To their benefit, Angular uses this behavior for their directives to make the components like native.
Tags that don't have a - inherit from HTMLUnknownElement. There's a good explanation of the upgrade process here: HTML5Rocks - Custom Elements - How elements are upgraded
Since Angular directives were designed in a time before the Custom Elements spec existed, they don't use a -. It's the standard that requires element names contain a -.
The dash is not required by Angular since there is no technical reason to require it. However, all large projects I have worked on prefix all components and directives with a two character and then dash prefix, e.g "ab-tab".
First, using dashes in names makes your syntax compatible with the Custom Elements standard, although Angular doesn't depending the spec.
Second, it helps with organization. Standard Angular directives are all prefixed with 'ng-'. By using your own prefix, people reading your code will be able to quickly distinguish between components from different libraries.

TypeScript in MVC

Im bulding a website using MVC4. Recently I've read about TypeScript. It looks really nice however I cannot find any use for it in a MVC website. Am I missing something? Do you use it? Where?
TypeScript is a pre-compiler for JavaScript. Hence you can use TypeScript only as a replacement for JavaScript (server-side, e.g. Node.js, or client-side, i.e. in the browser).
As you are probably writing MVC4 code with C#, TypeScript will be of no use for you in relation to MVC4.
Regarding the client-side it's somewhat different.
I guess the main point you need to know is that TypeScript is not (yet) just another language on the server, that you can exchange with C#.
I find it quite useful for building largish apps with lots of logic on the client. The interfaces help avoid some errors. It compiles to javascript so you could use it instead of javascript. If you're just writing a couple of lines I wouldn't bother though.
You can link to the generated javascript files from TS files directly in the script bundles or HTML. If you want to automatically link to many JS files, use require JS. This will save you having to link to many js files.

Is it possible to use third-party js libraries, like underscore, in a Firefox Add-On?

I'm using the Firefox Add-On SDK to port a Chrome extension to Firefox. In Chrome, it's trivial to load third-party libraries like Underscore or Backbone. In my particular case, I'm using jQuery, Underscore and Backbone to define models that communicate with cross-domain REST APIs.
It's unclear to me how you might do something similar in Firefox. From what I can see main.js corresponds directly to Chrome's background pages, but it doesn't appear there's a way to load js files.
Am I missing something?
Add-on SDK supports CommonJS modules sysem, same modules that are also used by nodejs
https://github.com/mozilla/addon-sdk/tree/master/app-extension
Underscore has a support for commonjs module format & there for can be loaded easily
https://github.com/documentcloud/underscore/blob/master/underscore.js#L54-L65
All you need is drop underscore in next to main.js and loaded it as follows:
var _ = require("./underscore")
I do believe backbone can also be loaded in a similar way as people have being using it
on nodejs.
It's won't work for the jQuery though, that's because context where add-on SDK modules
run is different from typical web page context with DOM, which is what jQuery is designed
to work with.
Now if you want to do cross domain requests there SDK comes with a module to do that:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/request.html
There is also another low level XHR module, that you could use instead:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/xhr.html
So if you just want to write models and talk to REST API it should be pretty trivial, I'm
not sure what's the role of jQuery in your use case. It implies DOM and UI you want to
display. If so there is several modules in SDK that would let you add custom UI for the
firefox and you can probably find useful tutorial on that subject:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/index.html

Playframework - GSPs and taglibs?

Is it possible to use the Grails GSP engine as the template engine in Play?
Including TagLibraries and such?`
What is neccessary to make that stuff work?
( I prefer the HTML style tags over the Ruby style ( ugly annoying )
The template engine is a pluggable system. For example, in Play 1.0 there is already the out of the box Groovy engine, the Scala engine within the Scala module, the Cambridge and Japid engines, also available as plugins.
For Play 2.0, there is already the Scala engine, and an implementation of the Groovy engine (I believe intended to be a plugin).
To answer your question of can it be done, the above clearly shows that it is possible, as others have done similar. To answer what is necessary, it depends on which platform you are targetting (Play 1 or 2), but there exists examples of both that you can follow to create your own module. I would highlight that Play 2.0 is not a stable release yet, so be cautious and prepare for some things to change over the next month or so, until a final release is issued.

Resources