angular js zeigt nichts auch nur wie einfache Ausdrücke. Ich bin verpflichtet, unter Code auszuführen, aber keine Hoffnung. Kann mir jemand helfen?Angular Js funktioniert nicht richtig
unter Code ist für die Anzeige angezeigt.
`<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script type="text/javascript" src="/../../Scripts/angularsample.js"></script>
</head>
<body ng-app="spiceApp">
<div>
<div ng-controller="SpicyController">
<p> lets try some code by using service </p>
<input ng-init="message='Girish'" ng-model="message" />
<button ng-click="notify(message);">Notify{{1+2}}</button>
<p>alert will display only by clicking three times.</p>
</div>
<div ng-controller="List">
<button ng-click="bringList()">getList</button>
<table>
<tr ng-repeat="app in appslist">
<td>
{{app.Name}}
</td>
</tr>
</table>
</div>
</div>
</body>
</html>`
js Code
var myApp = angular.module('spiceApp', []);
myApp.controller('SpicyController', ['$scope', '$http', 'userService', , function ($scope, $http, userService) {
//below code is using sservice
$scope.notify = function (msg) {
userService(msg);
};
}]);
myApp.controller('List', ['$scope', 'getList', function ($scope, getList) {
$scope.bringList = function() {
getList.getAppsList().then(function (list) {
$scope.appslist = list;
});
};
}]);
myApp.factory('getList', ['$http',function ($http) {
//this code for getting list from controller.
return getList.getAppsList=function(){
$http({
method: 'GET',
url: 'Home/GetAppsList'
})
.success(function (response) {
return response.data;
}, function (error) {
console.log(error);
});
}
}]);
myApp.factory('userService', ['$window', function (win) {
var msgs = [];
return function (msg) {
msgs.push(msg);
if (msgs.length == 3) {
win.alert(msgs.join('\n'));
msgs = [];
}
};
}]);`
Bitte sagen Sie mir, wo ich falsch bin. nichts funktioniert. Ausdruck wird wie {{1 + 2}} in der Ausgabe angezeigt.
Haben Sie Fehler in der Konsole? – Alteyss
jetzt bekomme ich Fehler in der Konsole ist: –
ReferenceError: getList ist nicht definiert bei Object. (angularsample.js: 36) bei Object.invoke. (Angularjs: 4708) bei Objekt erhält $ (Angularjs: 4547) bei Object.invoke (Angularjs: 4708) bei Angularjs : 4507 bei d (Angularjs: 4654) bei e (Angularjs: 4678) bei Object.invoke (Angularjs: 4700) bei P.instance (Angularjs: 10177) bei n (angular.js: 9096) (anonym) @ angular.js: 13642 –