0
서비스를 사용하여 컨트롤러 사이에 여러 개체 값을 전달 :데이터 보유 내가 서비스를 두 개의 컨트롤러를 가지고 설정
<div ng-controller="FirstCtrl">
<input type="text" ng-model="data.message">
<h1>{{ data.message }}</h1>
</div>
<div ng-controller="SecondCtrl">
<input type="text" ng-model="data.type">
<h1>{{ data.type }}</h1>
</div>
: 내 HTML에서
var myApp = angular.module('myApp', []);
myApp.factory('Data', function() {
return { message: "This is a message from a service", Type: "This is a type from a service" }
});
function FirstCtrl($scope, Data) {
$scope.data = Data;
}
function SecondCtrl($scope, Data) {
$scope.data = Data;
}
을, 나는이 값을 바인딩 입력이
그러나 서비스에서 돌아 오는 메신저는 모두 data.message
이고 data.type
은 없습니다.
왜 이런가요?
데이터 형식이어야합니다. 입력 - 오타가하나요? – michael
하하하 참으로! 고맙습니다! – Keva161