如何解决如何使用单向绑定将数据传递到组件?
请参阅下面的index.html,如何使用单向绑定将人员传递到DashboardController中? (这就是我需要构建的内容。)当我正确理解它时,index.html应该呈现:
仪表板人=迈克
谢谢您的建议。
<!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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。