Is there a way to dynamically render different templates for an angular 1.5 component

后端 未结 3 706
孤城傲影
孤城傲影 2021-02-02 15:04

I have a number of angular 1.5 components that all take the same attributes and data structure. I think they could be re-factored into a single component, but I need a way to dy

3条回答
  •  情深已故
    2021-02-02 15:42

    You can inject any service and set dynamic url

    angular.module('myApp').component("dynamicTempate", {
            controller: yourController,
            templateUrl: ['$routeParams', function (routeParams) {
               
                return 'app/' + routeParams["yourParam"] + ".html";
            
            }],
            bindings: {
            },
            require: {
            }
        });

提交回复
热议问题