AngularJS Bidirectional Binding and Dependency Inversion
1. Two-way binding:
UI<-->Data
Data -> UI (Data changes UI and change)
UI->Data (UI changes data and changes)
Data Change->UI Change Principle:
Listen to whether the data has changed, and update the UI data if it has changed.
UI Change->Data Change Principle:
<html> <body> <input type="text" name="name" value="" ng_model="a"> <script> = function(){ var a=''; var oTxt = ('text1'); = function(){ // UI value changes data changes a = ; } } </script> </body> </html>
2. Dependency injection:
Functions can decide what data or how many small data you need, instead of using whatever is transmitted outside.
2.1. The caller decides to give more small parameters
<script> function show(a,b,c){ (); } show(1); //The caller only gives 1 parameter, and the caller decides to give the parameter. </script>
2.2. Dependency injection (dependency inversion): The smaller parameters are required for the function. Just like show(a,b,c) requires 3 parameters
<script> function show(a,b,c){ (); } var scope = {a:12,b:15,c:99,qq:55,i:99}; //Suppose it is the parameter required by the function //Two steps to implement dependency inversion//1. Know what parameters to show var str = (); str=('{')[0].match(/\(.*)\/)[0].replace(/\S+/g,''); str=(1,-1); var arr=(','); //2. Give it the corresponding value var args=[]; for(var i=0;i<;i++){ args[i]=scope[arr[i]]; } (args); (null,args); </script>
Thank you for reading, I hope it can help you. Thank you for your support for this site!