Adding logic to Dashboard created programmatically
How do i add a controller, so i can add logic to my view?
I have created my dashboard programmatically in C#
[Weight(-10)]
public class TestDashboard : IDashboard
{
public string[] Sections => new[] { "content" };
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
public string Alias => "TestCustomDashboard";
public string View => "/Business/Dashboards/Test/View/test.html";
}
My file structure:
using a package.manifest i write which controller to use in that.
But now that i dont have that, how do i add the controller ?
angular.module("umbraco").controller("my.testDashboardController", function ($scope) {
var vm = this;
vm.headline = "My Custom Dashboard With Controller js";
});
in chrome it says "The controller with the name 'my.testDashboardController' is not registered."
in my view it looks like this now.
<umb-box>
<umb-box-content>
<div ng-controller="my.testDashboardController as vm">
<h3>{{vm.headline}}</h3>
<p>Dette er en test for at se om jeg kan lave et dashboard.</p>
</div>
</umb-box-content>
</umb-box>
Adding logic to Dashboard created programmatically
How do i add a controller, so i can add logic to my view?
I have created my dashboard programmatically in C#
My file structure:
using a package.manifest i write which controller to use in that. But now that i dont have that, how do i add the controller ?
Hi André
You have to create custom controller and ask work with it via Angular controller, so there is no way to register C# controller in the Dashboard class implementation, have a look at this tutorial - https://our.umbraco.com/documentation/tutorials/Creating-a-Custom-Dashboard/
Thanks, Alex
So i just need to include a manifest, that just registers the controller.
so something like this ?
and then the controller is something like this?
Yes, and if you need some serverside logic, you need to call it via AJAX request.
Cool, thx for the clarification.
Hope its okey to ask two more things ^^
in chrome it says "The controller with the name 'my.testDashboardController' is not registered."
in my view it looks like this now.
Can you see what i am doing wrong ?
And the second question ^^ https://our.umbraco.com/forum/using-umbraco-and-getting-started//101853-umbraco-8-dashboard-language-files-programmatically
Check that "test.controller.js" loaded on the page correctly.
i am not seeing under sources in chrome. I'm not sure how else to register it?
It should be loaded with client dependency, so try to increase client dependency versions and restart the application.
updated the number and rebuild and started the application again. Did not seem to change anything, still getting the same error.
then probably the issue with angular controller path "~/Business/Dashboards/Test/Controller/test.controller.js" or controller name in HTML
I moved the "dashboard" to App_Plugins, and then everything worked.
is working on a reply...