我是angularjs.的新手.我想在用户点击一个按钮时获取单选按钮值,但我的运气不好,它不起作用.这是代码
<label class="item item-radio">
<input type="radio" name="group" ng-model="user.answer" value="{{questions.quiz_ans_opt1}}">
<div class="item-content item-body">a) {{questions.quiz_ans_opt1}}</div><i class="radio-icon ion-checkmark"></i>
</label>
<label class="item item-radio item-body">
<input type="radio" name="group" ng-model="user.answer" value="{{questions.quiz_ans_opt2}}">
<div class="item-content item-body">b) {{questions.quiz_ans_opt2}}</div><i class="radio-icon ion-checkmark"></i>
</label>
<button class="button button-balanced button-block" ng-click="submitAnswer(user)">Submit</button>
Run Code Online (Sandbox Code Playgroud)
这是控制器
$scope.submitAnswer = function(user) {
//it output undefined error
alert(user);
}
Run Code Online (Sandbox Code Playgroud)
此外,我想禁用按钮,直到选中单选按钮,我怎么能这样做?
这是我想要在我的cordova android应用程序中实现的要求
当用户进入主页时,检查是否启用了gps.
如果未启用,我想指向用户打开位置设置.
第一部分是使用GPS探测器插件轻松制作的,第二部分是使用网络意图插件实现的.但它没有像我预期的那样工作.
if(!gps){
//gps is disabled try to show the location setting using webintent plugin
window.plugins.webintent.startActivity(
{
action: window.plugins.webintent.ACTION_LOCATION_SOURCE_SETTINGS,
},
function() {},
function() {
alert('Failed to open URL via Android Intent.');
console.log("Failed to open URL via Android Intent. URL: " + theFile.fullPath)
}
);
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误Failed to open URL via Android Intent.
我想在我的节点js聊天应用程序中加载本地jquery文件.我搜索了很多,但我找不到合适的解决方案.
<!doctype html>
<html>
<head>
<title>Socketio</title>
</head>
<body>
<!--This wont work -->
<script src="/socket.io/jquery.min.js"></script>
<!--This will work -->
<script src="/socket.io/socket.io.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我只是复制的jquery.js文件socket.iofolder.The socket.io.js正常文件加载但jQuery的文件didnt.Please帮我这里是我的index.js文件
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
server.listen(3000, function(){
console.log('listening on *:3000');
});
Run Code Online (Sandbox Code Playgroud) 我想在没有index.phpCodeIgniter 的情况下访问我的URL .这是我的Blog控制器
class Blog extends CI_Controller {
public function index() {
echo 'hello world';
}
public function about() {
echo 'about page';
}
}
Run Code Online (Sandbox Code Playgroud)
现在我可以访问index via http://localhost/codeigniter/index.php/Blog,但我需要使用此URL访问它http://localhost/codeigniter/Blog.
注意
我从配置文件.htaccess文件中删除了index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Environment
Run Code Online (Sandbox Code Playgroud)
Windows,XAMPP,PHP 5.6.3版
我的json数组:
[{"id":"7","name":"hello"},{"id":"7","name":"shan"},{"id":"7","name":"john"}
{"id":"7","name":"hello"}]
Run Code Online (Sandbox Code Playgroud)
我想name从一个字母开始得到一个与正则表达式匹配的新数组.
我正在使用正则表达式,但我不知道如何实现它.
这是我的代码:
var newitem=_.filter(result,item=>item.name='hello');
console.log(newitem);
Run Code Online (Sandbox Code Playgroud)
但它只返回严格的匹配name.
请帮我修改上面的内容,以便结果是所描述的新数组.
预期产出
当一个usertype字母h只显示该行
{"id":"7","name":"hello"}
Run Code Online (Sandbox Code Playgroud) 我使用这个推送插件在cordova中成功实现了推送通知.
一切正常,但如果收到多个通知只有最新通知的问题可用.我已经提到了这个答案,但它使用了较旧的插件.
这是我从答案中尝试的代码.
int notId=0;
try {
notId = Integer.parseInt(extras.getString("notId"));
}
catch(NumberFormatException e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID: " + e.getMessage());
}
catch(Exception e) {
Log.e(TAG, "Number format exception - Error parsing Notification ID" + e.getMessage());
}
notId++;
mNotificationManager.notify((String) appName, notId, mBuilder.build());
Run Code Online (Sandbox Code Playgroud) 我有一个ng-repeat <ul>列表.我想<br>在每个<ul>标签后插入.我怎样才能做到这一点?.
这是我的代码
<ul class="list" ng-repeat="result in results">
<li class="list__header">{{$index+1}}</li>
<li class="list__item">{{result.name}}</li>
<li class="list__item">{{result.address}}</li>
<li class="list__item">{{result.phone_number}}</li>
</ul><br><br>
Run Code Online (Sandbox Code Playgroud)
上面<br>没有渲染
我有这样的数组
$prebook=array(
'sourceCity'=>$_POST['source'],
'destinationCity'=>$_POST['dest'],
'doj'=>$_POST['doj'],
'routeScheduleId'=>$_POST['routeid'],
'boardingPoint'=>array(
'id'=>$id,
'location'=>$location,
'time'=>$time
),
'customerName'=>$_POST['fname'],
'customerLastName'=>$_POST['lname'],
'customerEmail'=>$_POST['email'],
'customerPhone'=>$_POST['mobileno'],
'emergencyPhNumber'=>$_POST['emc-number'],
'customerAddress'=>$_POST['address'],
'blockSeatPaxDetails'=>array(array(
'age'=>$_POST['age'][$key],
'name'=>$value,
'seatNbr'=>$_POST['seat-no'][$key],
'Sex'=>$_POST['gender'.$no],
'fare'=>$_POST['base-fare'][$key],
'totalFareWithTaxes'=>$_POST['amount'][$key],
'ladiesSeat'=>$ladies,
'lastName'=>$_POST['plname'][$key],
'mobile'=>$_POST['mobileno'],
'title'=>'Mr',
'email'=>$_POST['email'],
'idType'=>$_POST['idtype'],
'idNumber'=>$_POST['id-number'],
'nameOnId'=>$value,
'primary'=>true,
'ac'=>$ac,
'sleeper'=>$sleeper
)),
'inventoryType'=>$_POST['invtype']
)
Run Code Online (Sandbox Code Playgroud)
从这里我想让Json字符串看起来像这样
apiBlockTicketRequest:{"sourceCity":"Hyderabad","destinationCity":"Bangalore","doj":"2016-01-22","routeScheduleId":"6717","boardingPoint":{"id":"2889","location":"Mettuguda,Opp. Mettuguda Church","time":"04:50PM"},"customerName":"jj","customerLastName":"jjj","customerEmail":"shamonsha665@gmail.com","customerPhone":"7779","emergencyPhNumber":"7878","customerAddress":"gjgj","blockSeatPaxDetails":[{"age":"22","name":"hjhj","seatNbr":"G4","Sex":"F","fare":"900","totalFareWithTaxes":"945","ladiesSeat":false,"lastName":"hjhj","mobile":"7779","title":"Mr","email":"shamonsha665@gmail.com","idType":"Aadhar Card","idNumber":"jkjk","nameOnId":"hjhj","primary":true,"ac":false,"sleeper":false}],"inventoryType":"0"}
Run Code Online (Sandbox Code Playgroud)
这是我的代码
$data =json_encode($prebook);
$json='apiBlockTicketRequest:'.$data;
echo $json;
Run Code Online (Sandbox Code Playgroud)
但是当我使用此验证JSON字符串时,我将收到以下错误
期待对象或数组,而不是字符串.[代码1,结构1]
错误:字符串应该用双引号括起来.
我的CI应用程序中有一个ajax请求,这是我的cstom.js文件.
$(document).ready(function(){
var base_url='<?php echo base_url();?>';
$('#add-ct').click(function(){
$.ajax({
url:base_url+'stockmanagement/add_category',
data:{category:$('#category').val()},
success:function(data){
alert(data);
},
error:function(err){
alert('error'+err);
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
但是base_url没有重新定殖,当我检查调试控制台时,base_url它的打印方式与源代码一样,就像这样.
var base_url='<?php echo base_url(); ?>';
Run Code Online (Sandbox Code Playgroud)
UPDATE
我的javascript文件包含在视图文件中
<?php if($page=='add-category'){ echo '<script src="'.base_url().'/assets/js/custom.js"></script>'; }?>
Run Code Online (Sandbox Code Playgroud) 我尝试将 DOM PDF 库添加到我的 codeigniter 应用程序中
1.下载dompdf并将dompdf文件夹复制到libraries文件夹中。
Dompdf.php2.在libraries文件夹中创建名为的文件
在我的控制器中
public function pdf_test()
{
$this->load->library('Dompdf');
$this->Dompdf->loadHtml('hello world');
$this->pdf->render();
$this->pdf->stream("welcome.pdf");
}
Run Code Online (Sandbox Code Playgroud)
多姆pdf.php
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CodeIgniter PDF Library
*
* Generate PDF's in your CodeIgniter applications.
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author Chris Harvey
* @license MIT License
* @link https://github.com/chrisnharvey/CodeIgniter-PDF-Generator-Library
*/
require_once(dirname(__FILE__) . '/dompdf/autoload.inc.php');
class Pdf extends DOMPDF
{
/**
* Get an instance of …Run Code Online (Sandbox Code Playgroud) 我有这样的循环
foreach($this->input->post('users') as $value)
{
foreach($this->input->post('group_name') as $v)
{
echo $value.','.$v.'<br>';
}
}
Run Code Online (Sandbox Code Playgroud)
它的输出是
17,5
17,6
18,5
18,6
19,5
19,6
20,5
20,6
Run Code Online (Sandbox Code Playgroud)
现在我想使用上面的值创建一个像这样的关联数组。
array(
array(
'user_id' => 17,
'group_id' => 15
),
....
....
array(
'user_id' => 20,
'group_id' => 6
)
)
Run Code Online (Sandbox Code Playgroud)
我该怎么做,我已经在 foreach 循环中尝试过这个,但它会打印两个单独的数组。
$temp['user_id'][]=$v;
$temp['group_id'][]=$value;
Run Code Online (Sandbox Code Playgroud) 我想current在我的控制器中打印路线
namespace findetrip\Http\Controllers;
use Illuminate\Http\Request;
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index($page = 'home')
{
echo $route = Route::current();
return view('admin.'.$page,['pageName'=>$page]);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
未找到类'findetrip\Http\Controllers\Route'
我发现了许多类似于这个问题的问题,但没有找到合适的解决方案.