Javascript AngularJS使用$scope。(参数)

Javascript AngularJS使用$scope。(参数),javascript,html,angularjs,Javascript,Html,Angularjs,我有2个按钮和2个内容可编辑div。当我单击按钮时,我传递一个参数。现在在控制器中,我有一个$rootScope.$on()函数,它附加在contenteditable div中,因此我想在$rootScope.$on()方法中写入$scope.parameter,并将传递的值作为参数来代替参数 例如: <button type="button" ng-click="open('textModel')">Emojis</button> <div contentedi

我有2个
按钮
和2个
内容可编辑div
。当我单击
按钮时,我传递一个参数。现在在控制器中,我有一个$rootScope.$on()函数,它附加在
contenteditable div
中,因此我想在
$rootScope.$on()
方法中写入
$scope.parameter
,并将传递的值作为参数来代替参数

例如:

<button type="button" ng-click="open('textModel')">Emojis</button>
<div contenteditable="true" ng-model="textModel"></div>

<button type="button" class="btn btn-default" ng-click="open('textModel2')">Emojis</button>
<div contenteditable="true" ng-model="textModel2"></div>
现在在控制器中,我想把它写成
$scope.textModel+='Hello'
而不是
$scope.parameter
,因此当我按第一个按钮时,附加ng模型为textModel的
contenteditable div
,当我按第二个按钮时,附加ng模型为textModel2的
contenteditable div

请帮助

使用变量名访问属性:

$rootScope.$on('selectedCode', function(event, args) {
    $scope[btnid] += 'Hello';
});
$rootScope.$on('selectedCode', function(event, args) {
    $scope[btnid] += 'Hello';
});