過去数か月から、私は多くの JS を行ってきましたが、大学や本などから実際に学んだことはありません。
ここに質問があります:
$scope.selectTab = function($index, tab) {
$scope.template = $scope.templates[$index];
$scope.data.tabSelected = tab;
setTimeout(function() {
console.clear();
console.log($scope.template);
console.log(document.getElementById("SomeDiv"))
console.log("Going to draw now...")
draw_analytics($scope); // Draw on SomeDiv
}, 0);
}
上記のコードが機能している間。しかし、以下のものはそうではありません。
$scope.selectTab = function($index, tab) {
$scope.template = $scope.templates[$index];
$scope.data.tabSelected = tab;
console.clear();
console.log($scope.template);
console.log(document.getElementById("SomeDiv"))
console.log("Going to draw now...")
draw_analytics($scope);
}
タブ操作にAngularJSを使用していますが、それは無関係だと思います。上のコードでは、SomeDiv
dom を取得しようとすると、実際には HTML コンテンツが返されますが、下のコードでnull
は返されます。