Comments (5)
Whoa what is going on here? Would you care to clean up your question? I'm not able to follow.
from ui-router.
Hi Tim,
It looks like I did a copy/paste of some code and this showed up as HTML-speak...
I would like to see that a "templateUrl" can load any "myXxx.html" (partial) file, in which we can have as many times:
<script src="path/MyJavaScriptFile.js">< /script>
or:
<script type="text/javascript">
SOME JAVASCRIPT CODE HERE
< /script>
...with embedded controllers and other JavaScript code that run when the "myXxx.html" is loaded.
In other words, the classical ui-router would just need:
$stateProvider
.state( "myState" , {
views : {
"myView" : {
templateUrl : "myXxx.html",
BUT, NO NEED TO STATE THE CONTROLLER HERE,
BECAUSE THE JS CODE IS EMBEDDED IN 'myXxx.html'
}
},
Another really "cool" alternative would be to allow us to insert a JS file in the views:
templateUrl : "myXxx.html",
controllerUrl : "myXxx.js"
Thanks,
Marcus
from ui-router.
This does not sound like a good idea to me, kind of the opposite of accepted best practice of separation of concerns etc.
Mind you, you should be able to have script tags in templates, and the code should run at some point after the template is inserted into the DOM, but you won't have any control over when exactly, nor will $state be able to pick up particular constructs like controller functions in the code and somehow magically attach them to the correct states.
If you want to have different developers working on different parts of the app, just split it up into modules that have their own sets of JS files and templates, but bring the JS together via concat/minify at build time.
from ui-router.
Hi Karsten,
I'm surprised you closed this discussion and wrote the whole thing off as a bad idea. No point in arguing with you on this one, as I don't have the experience or appetite for this.
We are going to find another way, without ui-router, since you don't think its a valid request.
Perhaps the next versions of AngularJS will have something more suitable for multi-view solutions. iu-router doesn't have what it takes here.
Marcus
from ui-router.
@marcusbo I've given you multiple reasons why script tags in templates are a bad idea, and they have nothing to do with ui-router -- core Angular $route / ng-view work in the same way.
If you've got anything constructive to add, feel free to reopen the ticket or submit a pull request. If you think sulky remarks are the right way to get people to do work for you for free you've got a thing or two to learn yet about open source projects (and people in general).
from ui-router.
Related Issues (20)
- Resolve triggering twice HOT 1
- No services listed in 2.x docs HOT 2
- Optional params included on all similar routes HOT 1
- child states of lazy loaded future states get stuck in stateQueue HOT 1
- Transition Rejection : while upgrading angularjs from 1.5 to 1.8 using angular-route:1.0.0 HOT 1
- this.parent.parameters() is not a function while Upgrading angular-ui-router from 0.2.15 to 1.0.29
- I used transition.onStart() instead of stateChangeStart, but it shows .onStart is not a function.
- Documentation Broken HOT 1
- Access states' custom data-object in component
- dependency's version is not the same
- Update @uirouter/core dependency to 6.0.9 HOT 3
- Support for Standalone components HOT 1
- Is this library still being maintained? HOT 1
- V1.1.0 - TypeError: Cannot read properties of undefined (reading 'inherit') HOT 36
- AngularJS v1.3.5 - Page reloads on route change after npm install for latest build.
- Angular: StateService injected in custom library results in R3InjectorError HOT 1
- ui-router
- https://github.com/angular-ui/ui-router/tree/e8694114594d5aaf9f40e27b8ba194bca85595de
- str.split is nto a function HOT 1
- Please release the 1.1.0 version as soon as possible. HOT 6
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 ui-router.