ng-modelتوجيه AngularJS


مثال

اربط قيمة حقل الإدخال بمتغير في النطاق:

<div ng-app="myApp" ng-controller="myCtrl">
    <input ng-model="name">
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.name = "John Doe";
});
</script>

التعريف والاستخدام

يربط ng-modelالتوجيه عنصر نموذج HTML بمتغير في النطاق.

إذا كان المتغير غير موجود في النطاق ، فسيتم إنشاؤه.


بناء الجملة

<element ng-model="name"></element>

مدعوم من قبل عناصر <input> و <select> و <textarea>.


قيمه المعامل

Value Description
name The name of the property you want to bind to the form field.

الصفحات ذات الصلة

دروس الزاوي: نموذج التوجيه