Comments (13)
@ealtenho started on that yesterday here: https://github.com/angular/angular-hint/blob/master/load.js#L12
from angular-hint.
@btford, I'm not sure the direction of this issue? What are the goals here aside from what has already been done?
from angular-hint.
We already started on this, but there are a few pending tasks:
console.warn
for wrong config options, likeng-hint="bar"
when there is no module calledbar
- inclusive and exclusive modes – "use all hinting modules except X, Y, Z" and "use only hinting modules X, Y, and Z."
from angular-hint.
@caguillen214 would checking
console.warn for wrong config options, like ng-hint="bar" when there is no module called bar
be similar to your work for #1 ?
from angular-hint.
@btford for the inclusive and exclusive modes, would this be triggered by a flag like inclusive
or exclusive
entered with the ng-hint
tag? Or how were you envisioning this? Would inclusive or exclusive mode be the default?
from angular-hint.
There are a couple of possible ways to implement this. @caguillen214 – would be good for you and @ealtenho to brainstorm and choose something.
ng-hint="include x, y, z"
andng-hint="exclude x, y, z"
ng-hint-include="x, y, z"
andng-hint-exclude="x, y, z"
I think it's better to avoid mixing "inclusive" and "exclusive" modes. For example, none of these make sense to me:
ng-hint="+x, -y, +z"
ng-hint="{ x: true, y: false, z: true }"
Other hinting systems (like jshint, jslint, eshint) allow you to scope configuration options in a way that it can make sense to have both inclusive and exclusive rules in the same configuration. Although some of Angular corresponds directly to the DOM, in angular-hint we mostly decorate the service layer.
With this in mind, we should warn when a page has more than one ng-hint
. It might be good to suggest that the ng-hint
occur on <html>
or on the same element that has ng-app
.
from angular-hint.
So the implementation would be similar to what I do in hint-directive/hint-module if we decided to dynamically get the options loaded, by checking which modules have been created for the app.
It seems that it makes sense to just have like a hashmap of options we support. Since we don't have many options I feel the code would be simpler if we didn't dynamically load the ng-hint modules created and instead we just kept track of the ng-hint modules we support.
<html ng-app="app.js" ng-hint="['directive','dom']">
then something like (psuedo):
var ngHints = {
'all': 'all.js', 'directive' : 'hint-directive.js', 'dom': 'hint-dom.js', 'interpolation': 'hint-interpolation.js'
}
html.attr('ng-hint').value.forEach(function(hint) {
if(ngHints[hint])
load(ngHints[hint]);
else
throw new Error('No Angular-hint module found with name: '+hint);
}
from angular-hint.
With this in mind, we should warn when a page has more than one ng-hint. It might be good to suggest that the ng-hint occur on or on the same element that has ng-app.
I think this is a good idea.
from angular-hint.
ng-hint="['directive','dom']"
I think this is misleading in that it suggests that you could pass any angular expression in there. Because ng-hint
runs before angular is bootstrapped, it's impossible to bind to an angular expression.
Let's do this:
ng-hint
(includes all by default)ng-hint-include="x, y, z"
(comma-separated)ng-hint-exclude="x, y, z"
@ealtenho can you implement (and add tests for this?)
from angular-hint.
@btford
I've added a rough implementation of how I think this should work, but I'm having trouble getting tests to run. I assume that unit tests are the appropriate tool to use here, and I tried to start my implementation using TDD, but I can't seem to get the order of the bootstrapping correct with karma. When I run my tests I get the message that resumeBootstrap
is not a function.
I have (sort of) tested by hand using the sample application and appending the various ng-hint directives.
from angular-hint.
I will remove my broken unit tests and start working on E2E tests for this feature.
from angular-hint.
👍
from angular-hint.
This is now implemented. What remains is E2E testing as described in #7
from angular-hint.
Related Issues (20)
- RFC: Improving hints related to $parse HOT 1
- causing infinite digests on angular material wesbite
- $watch override makes one-time bindings in expressions to never clear the associated watch HOT 2
- Incorrectly reports digest time HOT 2
- TypeError: Cannot read property 'name' of undefined at module.exports HOT 15
- Error when loading angular-hint with requirejs HOT 7
- Validate directive / component definition HOT 1
- Script Error in requirejs environment, cannot load angular-hint. HOT 2
- Not seeing any warning /Error on console.
- Log / Warn for naming collisions in registerables (directives, controllers, filters etc.)
- hint.js giving error, Cannot read property 'name' of undefined HOT 2
- A semicolon error
- dist angular-hint.js file to be used without requirejs? HOT 7
- NPM install fails HOT 1
- Reconsidering bower? HOT 4
- humanReadableWatchExpression error on app load HOT 2
- Why controllers, dom and directives not working? HOT 1
- "$event is undefined"
- Unexpected end of expression when using 'angular-ui-bootstrap' HOT 4
- A bower-angular-hint would be nice HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-hint.