我试图通过用AngularJS在ng-click上触发一个函数来实时编辑元素。Angularjs不会奇迹般地创建输入元素进行编辑
这里是我的html:
<div class="row question">{{questions.1.name}} <a href="" class="glyphicon glyphicon-pencil" ng-click="editQuestion(questions.1.name)"></a></div>
而且JS:
function QuestionsMap($scope) {
$scope.questions = {
"1": {
"name": "Hello! Do you like to travel?",
"ID": "1",
"answer": {
"yes": {
"name": "Yes",
},
"no": {
"name": "No",
}
}
}
};
$scope.editQuestion = function (name) {
$scope.editing = $scope.questions[name];
};
}
我缺少什么? editQuestion函数编写不正确?
当NG-点击触发器现在会发生什么呢? – C1pher
什么也没有。 –
你想在$ scope.editing里存储什么值? – C1pher