Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用AngularJs在html中定义两个模型_Javascript_Angularjs - Fatal编程技术网

Javascript 如何使用AngularJs在html中定义两个模型

Javascript 如何使用AngularJs在html中定义两个模型,javascript,angularjs,Javascript,Angularjs,我是AngularJs的新手 如果我想用html定义两个模型 我如何定义它 我已经试过很多次了 请帮忙 <body ng-app="experiment"> <div ng-controller="functionCrtl" id="staff"> <div ng-modle="data1.data"> <ng-view></ng-view> </div> 我想动态加载两页,我该怎么办?但要回答您的问题,请阅

我是AngularJs的新手

如果我想用html定义两个模型

我如何定义它

我已经试过很多次了

请帮忙

<body ng-app="experiment">
<div  ng-controller="functionCrtl" id="staff"> 
<div ng-modle="data1.data">
   <ng-view></ng-view>  
</div>

我想动态加载两页,我该怎么办?

但要回答您的问题,请阅读以下内容

控制器:

 angular.module('myApp').controller('CreateUserCtrl', function ($scope) {

         $scope.firstname = 'John';
         $scope.surname = 'Doe';
});
HTML

<form ng-controller="CreateUserCtrl">
     <input ng-model="firstname " type="text" placeholder="firstname">
     <input ng-model="surname" type="text" placeholder="surname">
</form>


我们能看看您到目前为止做了什么吗?我们不是来给你代码的,而是来帮助你已经拥有的。你的控制器在哪里?
 angular.module('myApp').controller('CreateUserCtrl', function ($scope) {

         $scope.firstname = 'John';
         $scope.surname = 'Doe';
});
<form ng-controller="CreateUserCtrl">
     <input ng-model="firstname " type="text" placeholder="firstname">
     <input ng-model="surname" type="text" placeholder="surname">
</form>