Tell me please, how to create component in controller?
I have angularjs module with controller
let app = angular.module('testApp', []);
And i try to load component but it is not load.
app.controller('MainCtrl', ["$scope", function($scope) {
// I have an array with objects.
let arr = [{name: 'firstComponent', component: {
template: "<div>tech filter component</div>",
controller: [() => {
let $ctrl = this;
}]
}}];
angular.forEach(arr, (itemArr) => {
// Why it doesn't init from here ?
app.component(itemArr.name, itemArr.component)
});
}]);
And it is my html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>angularjs component</title>
</head>
<body ng-app="testApp" >
<div ng-controller="MainCtrl">
<first-component></first-component>
</div>
</body>
</html>