如何在输入例如void myfunction() // function is called periodically every 100 ms
{
...
mySubfunction(); // this function have to be called only once in the first call of myFunction() and than skipped each time after that.
} ...
的URL时处理这种情况,但问题是AngularJS无法处理它并且不加载页面,否则如果你转到http://localhost/#!/somepage/
通过它正常工作的索引文件。
我使用somepage
,我的路由脚本如下:
ui-router
当我在浏览器angular.module('WEBAPP', ['ui.router', 'bw.paging'])
.config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.when('', '/');
var states = [
{
name: 'home',
url: '/',
templateUrl: 'application/partials/home_header.html'
},
{
name: 'somepage',
url: 'somepage/',
templateUrl: 'application/partials/somepage.html',
},
{
name: '404',
url: '404/',
templateUrl: 'application/partials/404.html'
},
]
states.forEach(function (state) {
$stateProvider.state(state);
});
});
中输入网址时,如何进行正确的路由选择AngularJS会自动重定向到该网页。
答案 0 :(得分:1)
尝试没有for each.I可能是错的但我认为当你在这里使用每个只有最后一个状态将绑定$ stateprovider而不是绑定所有状态。试试这样。
$urlRouterProvider.otherwise('/');
$stateProvider
.state('home', {
url: '/',
templateUrl: 'application/partials/home_header.html'
})
.state('somepage', {
url: 'somepage/',
templateUrl: 'application/partials/somepage.html',
})
.state('404', {
url: '404/',
templateUrl: 'application/partials/404.html'
})
<强>编辑强>
更改此url: 'somepage/'
到此url: '/somepage'
当你打电话时,删除url.just !
中的http://localhost/#/somepage
标记即可。
var states = [
{
name: 'home',
url: '/',
templateUrl: 'application/partials/home_header.html'
},
{
name: 'somepage',
url: '/somepage',
templateUrl: 'application/partials/somepage.html',
},
{
name: '404',
url: '/404',
templateUrl: 'application/partials/404.html'
},
]
states.forEach(function (state) {
$stateProvider.state(state);
});
答案 1 :(得分:1)
使用此
public void handleResult(Result result) {
Log.w("handleResult", result.getText());
String RS1 = "play sound";
final MediaPlayer SoundMP = MediaPlayer.create(this, R.raw.sound_1);
if (result.getText(RS1)) {
SoundMP.start();
builder.setTitle("Now playing");
builder.setMessage("sound_1");
SoundMP.stop();
mScannerView.resumeCameraPreview(this);
}
}
});