我是 Angular 的新手并试图实现一个模态。关闭/关闭模态时出现问题 - 当我单击取消按钮时,没有任何反应。这是控制器代码:
angular.module('navApp')
// Passing the $modal to controller as dependency
.controller('HomeCtrl', ['$scope', '$uibModal', function ($scope, $uibModal) {
$scope.title = "Hello, Angm-Generator!";
$scope.open = function () {
var modalInstance = $uibModal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalCtrl'
});
};
}])
.controller('ModalCtrl', function ($scope, $uibModalInstance) {
// Added some content to Modal using $scope
$scope.content = "ModalCtrl, Yeah!"
// Add cancel button
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
})
Run Code Online (Sandbox Code Playgroud)
这是实际模态的模板视图
<!-- Modal Script -->
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header"> …Run Code Online (Sandbox Code Playgroud) 我在https://github.com/tayiorbeii/egghead.io_redux_course_notes/blob/master/08-Reducer_Composition_with_Arrays.md上关注了Dan Abramov的代码.
我收到错误消息"第22行的意外令牌"指的是... todo没想到它与Babel预设有关...状态正常工作.当我在map函数中用...替换... todo时,它会返回相同的错误.
///Reducer//
export default (state=[], action) => {
switch (action.type) {
case 'ADD_TODO':
return [...state,
{
id:action.id,
text: action.text,
completed:false
}
];
case 'TOGGLE_TODO':
return state.map(todo => {
if (todo.id !== action.id) {
return todo;
}
return {
...todo, //returning error
completed: !todo.completed
};
});
default:
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
我的通话代码:
it('handles TOGGLE_TODO', () => {
const initialState = [
{
id:0,
text: 'Learn Redux',
completed: false
},
{
id:1,
text: 'Go Shopping',
completed: …Run Code Online (Sandbox Code Playgroud)