Unten ist meine Definition von Controller. Wenn ich die Anwendung starte, bekomme ich
"$ rootScope ist nicht definiert".
Kann jemand mir helfen zu verstehen, was hier falsch ist.
var webadmin = angular.module('PcPortal')
.controller('environmentController',
[
'$scope', '$http', '$rootScope',
function ($scope, $http) {
$http.get('http://localhost:52240/api/PcpEnvironment/GetAllEnvironments')
.then(function (response) {
$scope.Environments = response.data;
});
$scope.findSelectedItem = function (index) {
var env = $scope.Environments[index];
$rootScope.selectedEnv = env;
};
}
]);
Html Linie Funktion aufzurufen ...
<td><a ng-click="findSelectedItem($index)" href="#/UpdateEnvironment">Update</a></td>
Fehler ist klar. 'function ($ scope, $ http, $ rootScope)' – Satpal
Sie vermissen den '$ rootScope' Parameter in Ihrer Controller Funktion ... – Cerbrus
Fügen Sie einfach $ rootScope zur Funktion hinzu ($ scope, $ http, $ rootScope) .. ........... –