我尝试将输入字段中的值绑定到ng-click上的方法参数。这是我得到的,但它不起作用,我不太确定是否可以这样做?:
require_once("Facebook/autoload.php"); //Facebook SDK v4
define('FACEBOOK_SDK_V4_SRC_DIR', 'Facebook/src/Facebook/');
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphObject;
use Facebook\FacebookRequestException;
$APP_ID = 'xxxxxxxxxxxxxxxx'; //app id
$APP_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; //app secret
//token
$TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; //access token
$ID = "xxxxxxxxxxxxxxxxxxxxx"; // facebook page id
FacebookSession::setDefaultApplication($APP_ID, $APP_SECRET);
$session_facebook = new FacebookSession($TOKEN);
$params = array(
"message" => 'Message',
"link" => "http://www.xxxxxxxxxxx.url",
"picture" => "http://www.xxxxxxxxxxxxxxx.url/images/image.jpg",
"name" => "How to Auto Post on Facebook with PHP",
"caption" => "www.test-url.url",
"description" => "Automatically post on Facebook with PHP using Facebook PHP SDK."
);
$response = (new FacebookRequest($session_facebook, 'POST', '/'.$ID.'/feed', $params))->execute()->getGraphObject();
答案 0 :(得分:21)
您应该对输入元素使用ng-model
指令。
<强>标记强>
<input type="text" name="name" ng-model="post.PostId" />
<button ng-click="getById(post.PostId)"></button>
<h1>{{post.Title}}</h1>
这将处理与您的属性post.PostId
的双向模型绑定。您的ng-click
指令将获取输入元素中输入的正确值。
查看我的工作Plunk:)