【发布时间】:2015-12-10 11:27:06
【问题描述】:
我目前被困在一个简单的问题上:
我有一个controller.js
app.controller('WizardCtrl', function ($scope) {
$scope.send = function() {
console.log($scope.isPasswordChanged)
}
});
我的观点.html
isPasswordChanged: {{ isPasswordChanged }} <br>
<update-password-field is-changed="isPasswordChanged"></update-password-field>
<button ng-click="send()"></button>
我的指令.js
app.directive('updatePasswordField', function () {
return {
restrict: 'E',
scope: {
isChanged: "="
},
templateUrl: "password-field-directive.html",
link: function (scope) {
// some magic to set isChanged value to true of false
}
}
});
所以在我的 view.html 中,我可以看到“isPasswordChanged”的变化,它以某种方式在我的 $scope 中,但是如果我 console.log($scope) 则“isPasswordChanged”不存在。
为什么以及如何让它呈现?
【问题讨论】:
-
你把
console.log($scope)放在哪里了? -
什么时候调用
send函数?你能提供工作样本吗? -
@K.Toress 在我的 send() 函数中,我更新了我的 view.html
-
@Grundy 我更新了我的 view.html
-
我认为@Craig 有答案
标签: javascript angularjs