Base solution for your next web application
Open Closed

How to use .cshtml from another module? #2699


User avatar
0
bilalhaidar created

Hi, In doing an effort to modularize my app more, I'm making use of a blog module that has the path of: App/Main/views/blog/blog.cshtml and blog.js

Inside blog.js:

(function() {

    angular.module('app').config([
        '$stateProvider',
        function ($stateProvider) {
            $stateProvider
                .state('blog', {
                    url: '#/blog',
                    templateUrl: '~/App/Main/views/blog/blog.cshtml',
                    menu: 'SampleBlog.AdminPage'
                });
        }
    ]);

    angular.module('app').controller('app.views.blog', [
        '$scope', 'abp.services.blog.post',
        function ($scope, postService) {
            var vm = this;

            vm.posts = [];

            postService.getPosts({
                maxResultCount: 1000
            }).success(function(result) {
                vm.posts = result.items;
            });
        }
    ]);
})();

Also, the BlogNavigationProvider looks like this:

public class BlogNavigationProvider : NavigationProvider
    {
        public override void SetNavigation(INavigationProviderContext context)
        {
            context.Manager.MainMenu.Items.Add(
                new MenuItemDefinition(
                    "SampleBlog.AdminPage",
                    new FixedLocalizableString("Blog"),
                    url: "/blog",
                    icon: "fa fa-list"
                    )
                );
        }
    }

The menu "Blog" appears in the backend. But when I click on it, it says

Error: Could not resolve '/blog' from state 'host.tenants'

I marked both blog.cshtml and blog.js as Embedded resources.

What else should be done?

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Whan happens when you move your angularjs route definition to main app ? Does that work ?

  • User Avatar
    0
    bilalhaidar created

    Hey Ismail. I had a complete mess yesterday. I dropped all those efforts to create a separate module.

    I am now making sure that my custom code is under 1 folder in each of .Core and .Application.

    The rest of things I will keep track of, so that when I upgrade my files and nuget packages, i know when to replace manually.

    I don't think other than that it will work :(

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Some of our customers managed to make this work but we didn't try it actually. If you are doing this work for easily upgrading the solution, this will work well I think.

    Thanks for your feedback as always.