Angular UI Bootstrap Datepicker
을 다운로드했으며 해당 범위에 해당 컨트롤러에 액세스해야합니다. 그러나 Datepicker에서 코드를 편집하지 않고 어떻게해야하는지는 전혀 알지 못합니다. 그렇다고 생각합니다.다른 모듈의 컨트롤러간에 데이터를 공유하는 방법
그래서 난 내 자신의 응용 프로그램/모듈, myApp
을 가지고 있고 나는 ui.bootstrap.datepicker
응용 프로그램/모듈에 UibDatepickerController
및 UibDaypickerController
에 대한 액세스를 필요로하는 컨트롤러 MyController
을 보유하고 있습니다. 그리고 ui.bootstrap.datepicker
모듈의 코드를 변경하고 싶지 않습니다.
이것은 기본적으로 the same problem입니다. 이전에 게시했지만 생각보다 많이 생각했습니다. (이 중 50 시간을 소비했습니다 : D)
This solution 서비스를 삽입 할 수있는 것처럼 컨트롤러를 삽입 할 수 없기 때문에 작동하지 않습니다. 여기
내 디자인의 종류 :
컨트롤러 :
function MyCtrl() {
var vm = this;
vm.dt = new Date();
vm.options = {
...
};
vm.refresh = function() {
//returns initialized value all the time (current date)
console.log(vm.dt);
$("#calendar").data("$uibDatepickerController").refreshView();
}
};
angular.module('myApp')
.controller('MyCtrl', MyCtrl);
HTML : 다음 주입
app.factory('thisfactory',function(){
var data = null;
var get = function(){
return data;
}
var save = function(newData){
data = newData;
}
return {get:get,save:save}
});
:
<div ng-controller="CalendarCtrl as calCtrl">
<pre>Selected date is: <em>{{calCtrl.dt | date:'fullDate' }}</em>
</pre>
<div style="display:inline-block">
<div uib-datepicker="" id="calendar" ng-model="calCtrl.dt" datepicker-options="calCtrl.options"></div>
</div>
<button ng-click="calCtrl.refresh()">Refresh</button>
</div>
구체적으로 무엇이 필요합니까? 선택한 날짜/일 또는 내부 내용? – MPawlak
선택한 날짜와 또한 내 컨트롤러에서 내 변수에 액세스 할 수 있도록 ui.bootstrap.datepicker 모듈이 필요합니다. – Dope
날짜에 컨트롤러의 변수에 요소의 값을 바인딩하는 것이 좋습니다. 직접 컨트롤러에서 컨트롤러 액세스로 나일 즈의 대답은 원하는 것입니다. 당신은 바이올린이나 비슷한 것을 게시 할 수있어서 당신이 가고자하는 곳을 더 잘 이해할 수 있습니까? – MPawlak