0

Referring to the index.html below, how should I pass person into the DashboardController using one-way binding? (That's what I'll need to build from.) When I get it right, index.html should render:

Dashboard person = Mike

Thanks for any suggestions.

    <!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Dashboard</title>
    <script src="https://code.angularjs.org/1.8.0/angular.min.js"></script>
    <script>
        (function (angular) {
            'use strict';
            angular.module('dashboardApp', []);
        })(window.angular);

        (function (angular) {
            'use strict';
            function DashboardController($scope, $element, $attrs) {
                var ctrl = this;
                ctrl.userid = "Mike";
            }

            angular.module('dashboardApp').component('dashboard', {
                template: "<p>Dashboard person = {{$ctrl.person}}</p>",
                controller: DashboardController,
                bindings: {
                    person: '<'
                }
            });
        })(window.angular);
    </script>
</head>

<body ng-app="dashboardApp">
    <dashboard person="$ctrl.userid"></dashboard>
</body>

</html>

0 Answers0