1

段落の横にあるボタンのクラスにアクセスしようとしています。フォーカスが段落に移るとすぐに、ボタンのクラスが変更されます。以下のコードの HTML を参照してください。

    <div>
    <span id="key" class="col-lg-2">email : </span>
    <span ng-focus="focused($event)" id="value" contenteditable="true">abcd@abc.com</span>
    <input type="submit" name="update" value="update" 
                 class="update-hide" data-ng-click="updateValue($event)">
    </div>

コントローラーの角度コードは次のとおりです。

var TestParseController = function($scope, $window, $http, $routeParams, $sce,
        $compile) {
    $scope.focused = function(focusedValue) {
        var par = focusedValue.target.parentNode;
        var nodes = par.childNodes;
        nodes[2].className="update-regular";
        }
    }

これは角度のある方法でどのように行うことができますか? $$nextSibling のようなものは知っていますが、クラス名へのアクセスは問題があります。私はたくさんグーグルで検索しましたが、何も見つかりませんでした。助けてください!!!

ボタンのIDもハードコーディングできない動的な方法を提案してください。

4

1 に答える 1