そこには多くの回答がありますが、それほど重要ではないので、私は再度尋ねます。引数 'myCtrl'は関数ではありません。定義されていません。永続的です
<!DOCTYPE html>
<html ng-app="" ng-controller="myCtrl">
<body>
<h3>Select some text </h3>
<div ng-mouseup="showSelectedText()">
Do you think that facebook, twitter, linkedin are designed to make people addict ?, Then you have to read this article. The most popular social networking sites are following people's habit. It is not concept, it is people's habit
</div>
<br/>
<h3>Selected Text</h3>
<div ng-bind="selectedText"></div>
<script>
function myCtrl($scope) {
$scope.showSelectedText = function() {
$scope.selectedText = $scope.getSelectionText();
};
$scope.getSelectionText = function() {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (window.getSelection && window.getSelection.type != "Control") {
text = document.selection.createRange().text;
}
return text;
};
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
</body>
</html>
そして、それは私にエラーを返す保持何らかの理由:私は、私が見つけた角度コードの平和を使用しようとしている
Argument 'myCtrl' is not a function, got undefined
ng-app="myApp"
に変更しようとしたとき、私はこれを取得していますエラー:
Error: $injector:modulerr
Module Error
私は新しい角度バージョンでNG-コントローラを使用する構文を中心に作られているいくつかの移行があることを理解し、私は非常に私がになってるかを把握することはできません 行う。
ありがとうございます! Amir
は([ここで正常に動作します] http://plnkr.co/edit/s8SwnY8og1xR8Yt8OKbN?p =プレビュー)を正確なコードで入力します。しかし、グローバル関数はバージョン1.3の直後にコントローラとしてサポートされていません。 – charlietfl