Is there a way to include your own angular module into the app? The only way I've been able to develop say a service is to include it into the umbraco.resources (per the documentation) module however that might cause conflicts with existing services.
I might suggest that each plugin creates its own injected module based on its alias name that way its own services/directives won't pollute the existing umbraco system ones...
var app = angular.module('umbraco', [
'umbraco.filters',
'umbraco.directives',
'umbraco.resources',
'umbraco.services',
'umbraco.packages',
'ngCookies',
'ngSanitize',
'ngMobile',
'blueimp.fileupload',
'pmg.MySuperPlugin' // loop over each plugin to generate these modules
]);
The plugin's javascript setup would include the module definition similar to what happens today (except not using the umbraco module):
For anyone looking for syntax to help out here is an example of mine needing to inject/require a module
var app = angular.module("umbraco");
//This is my Angular module that I want to inject/require
app.requires.push('tableSort');
app.controller("Analytics.BrowserController", function ($scope, $location, statsResource) {
//Do stuff here...
});
@Warren - I'm currently looking into 'fixing' this for 7.3 so you could include angular module names to include in your manifest. However before I do this it would be good to know if you think that that above code is sufficient? To me, this dynamic including of a module works well and doesn't pollute the manifest with more features and obviously requires far less work in the core.
Let me know if you think it's important to be able to include angular module names in your manifest or if doing it this way is acceptable :)
Hey Shannon,
Yes I thin the solution is perfectly acceptable but obviously an easier way with a manifest file would be a nice to have but not a necessity IMO.
Shannon - the current way works fine and is already utilized by a number of packages, so I don't really see any problem with continuing it. Maybe it should be properly documented, though, so it is seen as "official" and is easily discoverable?
I think if you did go down the manifest road, then it would be important that the above "push" method continued to work, since it's already being used.
I'm trying to make a custom property editor, where I want to use the ui.autocomplete module. I can't figure out where everything goes to be able to do this...
In which files are you guys adding:
var app = angular.module("umbraco");
//This is my Angular module that I want to inject/require
app.requires.push('tableSort');
app.controller("Analytics.BrowserController", function ($scope, $location, statsResource) {
//Do stuff here...
});
?
When that doesn't work I suspect that I haven't managed to get the actual autocomplete.js file included. Which I tried doing in the file "install.loader.js". Where are you guys adding the actual file for the external module?
Amg... I knew that... I'm obviously adding my controller there. It just didn't occur to me that I actually have to add the required file there too...
Shame on me...
Including an angular module
Is there a way to include your own angular module into the app? The only way I've been able to develop say a service is to include it into the umbraco.resources (per the documentation) module however that might cause conflicts with existing services.
I might suggest that each plugin creates its own injected module based on its alias name that way its own services/directives won't pollute the existing umbraco system ones...
Right now we have to do this:
And maybe it might be better if..
The angular bootstrap will look like this:
The plugin's javascript setup would include the module definition similar to what happens today (except not using the umbraco module):
Or, is there a way to do this that I'm missing?
Hey
I'm afraid currently you cant do it, its on the todo, but not done yet I'm afraid ideally we will enable this through the package manifest
/Per
Thanks. As for building non trivial packages, I think it is a very important requirement.
yup, currently planned for 7.1 so we do know its important :)
You can do it using requires.
app is defined by umbraco.
app.requires.push('ngGrid');
This also works for Umbraco 8.8 :-)
Where do you add app.requires.push('ngGrid') - in your controller?
Yes, before my controller starts
Thanks, Volodymyr, I tried this and it works - great find :)
Hey Volodymyr, Thanks for your answer.
For anyone looking for syntax to help out here is an example of mine needing to inject/require a module
Thanks Warren/Volodymyr,
It worked.
@Warren - I'm currently looking into 'fixing' this for 7.3 so you could include angular module names to include in your manifest. However before I do this it would be good to know if you think that that above code is sufficient? To me, this dynamic including of a module works well and doesn't pollute the manifest with more features and obviously requires far less work in the core.
Let me know if you think it's important to be able to include angular module names in your manifest or if doing it this way is acceptable :)
Hey Shannon,
Yes I thin the solution is perfectly acceptable but obviously an easier way with a manifest file would be a nice to have but not a necessity IMO.
Shannon - the current way works fine and is already utilized by a number of packages, so I don't really see any problem with continuing it. Maybe it should be properly documented, though, so it is seen as "official" and is easily discoverable?
I think if you did go down the manifest road, then it would be important that the above "push" method continued to work, since it's already being used.
Yup, i agree on the documentation side of things, just need to clean up and figure out where that is supposed to go
Hi there!
I'm trying to make a custom property editor, where I want to use the ui.autocomplete module. I can't figure out where everything goes to be able to do this...
In which files are you guys adding:
?
When that doesn't work I suspect that I haven't managed to get the actual autocomplete.js file included. Which I tried doing in the file "install.loader.js". Where are you guys adding the actual file for the external module?
Could really use some help here, cuz Im stuck...
/Mats
Comment author was deleted
@Matz you need to add the actual file to the package.manifest
Comment author was deleted
@Matz as you can see in the docs there is a javascript root element that you can use http://umbraco.github.io/Belle/#/tutorials/manifest
Amg... I knew that... I'm obviously adding my controller there. It just didn't occur to me that I actually have to add the required file there too... Shame on me...
Thanks alot! I'll try that :)
Comment author was deleted
@Mats no worries, hope it works now :)
is working on a reply...