【发布时间】:2016-01-14 20:50:09
【问题描述】:
我正在使用 ionic 框架,我正在尝试在拍照后加载另一个视图。
我有以下控制器:
.controller('SnapCtrl', function($scope, $cordovaCamera) {
$ionicPlatform.ready(function(){
var options = {
quality : 75,
destinationType : Camera.DestinationType.DATA_URL,
sourceType : Camera.PictureSourceType.CAMERA,
allowEdit : false,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 400,
targetHeight: 400,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};
$cordovaCamera.getPicture(options).then(function(imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}, function(err) {
// An error occured. Show a message to the user
});
})
})
这是我页面的代码:
config(function($stateProvider, $urlRouterProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
// Each tab has its own nav history stack:
.state('tab.export', {
url: '/export',
views: {
'tab-dash': {
templateUrl: 'templates/tab-dash.html',
controller: 'DashCtrl'
}
}
})
.state('tab.users', {
url: '/users',
views: {
'tab-chats': {
templateUrl: 'templates/tab-chats.html',
controller: 'ChatsCtrl'
}
}
})
.state('tab.snapshot', {
url: '/snapshot',
views: {
'tab-chats': {
templateUrl: 'templates/tab-snapshot.html',
controller: 'SnapCtrl'
}
}
})
/* .state('tab.chat-detail', {
url: '/chats/:chatId',
views: {
'tab-chats': {
templateUrl: 'templates/chat-detail.html',
controller: 'ChatDetailCtrl'
}
}
})*/
.state('tab.settings', {
url: '/settings',
views: {
'tab-account': {
templateUrl: 'templates/tab-account.html',
controller: 'AccountCtrl'
}
}
});
当用户访问快照页面时,上面的代码会自动打开相机。例如,我想在拍照后(功能在“快照”页面和控制器中)加载另一个页面,例如“设置”并显示在该页面上拍摄的照片。
我正在阅读有关声明 $state.go('app.home') 的一些内容,但它对我不起作用,或者我可能以错误的方式使用它,我可以做些什么来实现我正在寻找的东西,简而言之:拍摄一张照片并加载一个带有拍摄照片的页面。
问候。
【问题讨论】:
标签: ios angularjs cordova ionic-framework ionic