Here's my simple controller and directive:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope, $q) {
var myObject = {
name: "Dingus",
favoriteFood: "Chicken",
};
var itemDeferred = $q.defer();
$scope.item = itemDeferred.promise;
var resolveIt = function() {
itemDeferred.resolve(myObject);
};
resolveIt();
}
myApp.directive('promised', function() {
return {
restrict: 'E',
scope: { boundModel: '=' },
template: '<input type="text" ng-model="boundModel">',
};
});
The scope item is resolved from a promise. When I use ng-model
in the HTML, why doesn't the input update the item, and why won't the directive even let me type?
See this fiddle for a working example: http://jsfiddle.net/winduptoy/XmBxK/