Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.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 在模型中无法访问选定对象中的角度js属性_Javascript_Angularjs_Html - Fatal编程技术网

Javascript 在模型中无法访问选定对象中的角度js属性

Javascript 在模型中无法访问选定对象中的角度js属性,javascript,angularjs,html,Javascript,Angularjs,Html,基本上我想要$scope.Newmodel.ControlPrefix变量中的值,即$scope.Newmodel.ControlPrefix $scope.Newmodel = { Title: "New Question Title", ControlPrefix: $scope.selectedQuestion.ControlPrefix }; 我没有发现任何问题,请检查和验证- var-app=angular.module(“myApp”,[

基本上我想要
$scope.Newmodel.ControlPrefix
变量中的值,即
$scope.Newmodel.ControlPrefix

 $scope.Newmodel = {
        Title: "New Question Title",
        ControlPrefix: $scope.selectedQuestion.ControlPrefix
    };

我没有发现任何问题,请检查和验证-

var-app=angular.module(“myApp”,[]);
应用程序控制器(“myCntr”,功能($scope){
$scope.tabnames=[
{
“$id”:“1”,
“ID”:3,
“标题”:“文本”,
“ControlPrefix”:“txt”
},
{
“$id”:“2”,
“ID”:4,
“标题”:“编号”,
“ControlPrefix”:“num”
},]
$scope.NewQuestionmodel={
标题:“,
问题类型ID:“”,
};   
$scope.Dosomething=函数(selectedQuestion){
$scope.NewQuestionmodel.Title=selectedQuestion.Title;
$scope.NewQuestionmodel.QuestionTypeID=selectedQuestion.ID;
}
});


从用户界面-所选问题标题:{{selectedQuestion.Title}}
从用户界面-所选问题ID:{{selectedQuestion.ID}}
从用户界面-所选问题控制前缀:{{selectedQuestion.ControlPrefix}}


从后端选择的问题标题为{{NewQuestionmodel.Title}}
从后端选择的问题ID为{{NewQuestionmodel.QuestionTypeID}
Title在模型中是可访问的?是的,Title可以在UI中像{{selectedQuestion.Title}}一样访问,但在模型中它不起作用。您的意思是
$scope.Newmodel.ControlPrefix
$scope.selectedQuestion.ControlPrefix
?因为这是您在
ng车型上使用的方法,所以建议您提供一个。如果没有完整的代码上下文$scope.Newmodel={Title:“New Question Title”,ControlPrefix:$scope.selectedQuestion.ControlPrefix},很难调试;在这里,我尝试在$scope.Newmodel内同步$scope.selectedQuestion.ControlPrefix的值,即当我访问$scope.Newmodel.ControlPrefix的值时,我应该能够获得该值。现在,在UI上,值出现了,但在模型上没有,基本上我想设置NewQuestionmodel.QuestionTypeID的值(上面的示例链接)@user3815413您必须在更改事件时进行设置
 $scope.Newmodel = {
        Title: "New Question Title",
        ControlPrefix: $scope.selectedQuestion.ControlPrefix
    };
 **tabnames array/objet is below**
   {
  "$id": "1",
  "ID": 3,
  "Title": "Text",
  "ControlPrefix": "txt"
  },

  {
 "$id": "2",
 "ID": 4,
 "Title": "Number",
 "ControlPrefix": "num"
  },