Angular JS 中是否有等效于 React JS 的道具?

Is there an equivalent in Angular JS of props from React JS?

我正在学习 angularJS,我想知道是否有像 React 中那样的 props 等价物。更具体地说,一种添加我在另一个文件中定义的道具的方法。这将使我在 angular 中编码的网站更有效率,但我在 Angular 中找不到等效项。

在 AngularJS 中有一种方法可以做类似的事情。它被称为指令。在您的情况下,您想创建一个 restrict 设置为 'E'.
的指令 'E' 告诉编译器它将是生成的 HTML.

中的一个元素
angular.module('scopeDirective', [])
.controller('app', ['$scope', function($scope) {
  $scope.naomi = { name: 'Uriel', address: '1600 Amphitheatre' };
  $scope.igor = { name: 'Bitton', address: '123 Somewhere' };
}])
.directive('customer', function() {
  return {
    restrict: 'E',
    scope: {
      customerInfo: '=info'
    },
    templateUrl: 'customer.html'
  };
});

restrict 之后的 scope 对象定义了您希望此指令接受的各种属性。这类似于 props 在 React 中的工作方式。在该对象中,您可以看到 customerInfo,它对应于指令的隔离范围 属性。值 (=info) 告诉 $compile 绑定到信息属性。
templateUrl 映射到此指令的 HTML。

使用上述指令将如下所示:

<div ng-controller="app">
  <customer info="uriel"></customer>
  <hr>
  <customer info="bitton"></customer>
</div>

请参阅 Directives 上的 AngularJS 文档。

NOTE: Instead of trying to do something in AngularJS that is similar to how you do things in React or any other framework/library, I would suggest you do not instead embrace the current framework's capability and use it as is without trying to compare way of achieving similar things as this can lead to frustration down the road.

希望此答案对您有用。